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/init.h>
47 #include <linux/module.h>
48 #include <linux/errno.h>
49 #include <linux/spinlock.h>
50 #include <linux/workqueue.h>
53 #include <asm/uaccess.h>
54 #include <asm/byteorder.h>
59 * Structure used to define /proc entries
61 typedef struct _i2o_proc_entry_t
63 char *name; /* entry name */
64 mode_t mode; /* mode */
65 read_proc_t *read_proc; /* read func */
66 write_proc_t *write_proc; /* write func */
69 // #define DRIVERDEBUG
71 static int i2o_proc_read_lct(char *, char **, off_t, int, int *, void *);
72 static int i2o_proc_read_hrt(char *, char **, off_t, int, int *, void *);
73 static int i2o_proc_read_status(char *, char **, off_t, int, int *, void *);
75 static int i2o_proc_read_hw(char *, char **, off_t, int, int *, void *);
76 static int i2o_proc_read_ddm_table(char *, char **, off_t, int, int *, void *);
77 static int i2o_proc_read_driver_store(char *, char **, off_t, int, int *, void *);
78 static int i2o_proc_read_drivers_stored(char *, char **, off_t, int, int *, void *);
80 static int i2o_proc_read_groups(char *, char **, off_t, int, int *, void *);
81 static int i2o_proc_read_phys_device(char *, char **, off_t, int, int *, void *);
82 static int i2o_proc_read_claimed(char *, char **, off_t, int, int *, void *);
83 static int i2o_proc_read_users(char *, char **, off_t, int, int *, void *);
84 static int i2o_proc_read_priv_msgs(char *, char **, off_t, int, int *, void *);
85 static int i2o_proc_read_authorized_users(char *, char **, off_t, int, int *, void *);
87 static int i2o_proc_read_dev_name(char *, char **, off_t, int, int *, void *);
88 static int i2o_proc_read_dev_identity(char *, char **, off_t, int, int *, void *);
89 static int i2o_proc_read_ddm_identity(char *, char **, off_t, int, int *, void *);
90 static int i2o_proc_read_uinfo(char *, char **, off_t, int, int *, void *);
91 static int i2o_proc_read_sgl_limits(char *, char **, off_t, int, int *, void *);
93 static int i2o_proc_read_sensors(char *, char **, off_t, int, int *, void *);
95 static int print_serial_number(char *, int, u8 *, int);
97 static int i2o_proc_create_entries(void *, i2o_proc_entry *,
98 struct proc_dir_entry *);
99 static void i2o_proc_remove_entries(i2o_proc_entry *, struct proc_dir_entry *);
100 static int i2o_proc_add_controller(struct i2o_controller *,
101 struct proc_dir_entry * );
102 static void i2o_proc_remove_controller(struct i2o_controller *,
103 struct proc_dir_entry * );
104 static void i2o_proc_add_device(struct i2o_device *, struct proc_dir_entry *);
105 static void i2o_proc_remove_device(struct i2o_device *);
106 static int create_i2o_procfs(void);
107 static int destroy_i2o_procfs(void);
108 static void i2o_proc_new_dev(struct i2o_controller *, struct i2o_device *);
109 static void i2o_proc_dev_del(struct i2o_controller *, struct i2o_device *);
111 static int i2o_proc_read_lan_dev_info(char *, char **, off_t, int, int *,
113 static int i2o_proc_read_lan_mac_addr(char *, char **, off_t, int, int *,
115 static int i2o_proc_read_lan_mcast_addr(char *, char **, off_t, int, int *,
117 static int i2o_proc_read_lan_batch_control(char *, char **, off_t, int, int *,
119 static int i2o_proc_read_lan_operation(char *, char **, off_t, int, int *,
121 static int i2o_proc_read_lan_media_operation(char *, char **, off_t, int,
123 static int i2o_proc_read_lan_alt_addr(char *, char **, off_t, int, int *,
125 static int i2o_proc_read_lan_tx_info(char *, char **, off_t, int, int *,
127 static int i2o_proc_read_lan_rx_info(char *, char **, off_t, int, int *,
129 static int i2o_proc_read_lan_hist_stats(char *, char **, off_t, int, int *,
131 static int i2o_proc_read_lan_eth_stats(char *, char **, off_t, int,
133 static int i2o_proc_read_lan_tr_stats(char *, char **, off_t, int, int *,
135 static int i2o_proc_read_lan_fddi_stats(char *, char **, off_t, int, int *,
138 static struct proc_dir_entry *i2o_proc_dir_root;
143 static struct i2o_handler i2o_proc_handler =
151 0xffffffff // All classes
155 * IOP specific entries...write field just in case someone
158 static i2o_proc_entry generic_iop_entries[] =
160 {"hrt", S_IFREG|S_IRUGO, i2o_proc_read_hrt, NULL},
161 {"lct", S_IFREG|S_IRUGO, i2o_proc_read_lct, NULL},
162 {"status", S_IFREG|S_IRUGO, i2o_proc_read_status, NULL},
163 {"hw", S_IFREG|S_IRUGO, i2o_proc_read_hw, NULL},
164 {"ddm_table", S_IFREG|S_IRUGO, i2o_proc_read_ddm_table, NULL},
165 {"driver_store", S_IFREG|S_IRUGO, i2o_proc_read_driver_store, NULL},
166 {"drivers_stored", S_IFREG|S_IRUGO, i2o_proc_read_drivers_stored, NULL},
167 {NULL, 0, NULL, NULL}
171 * Device specific entries
173 static i2o_proc_entry generic_dev_entries[] =
175 {"groups", S_IFREG|S_IRUGO, i2o_proc_read_groups, NULL},
176 {"phys_dev", S_IFREG|S_IRUGO, i2o_proc_read_phys_device, NULL},
177 {"claimed", S_IFREG|S_IRUGO, i2o_proc_read_claimed, NULL},
178 {"users", S_IFREG|S_IRUGO, i2o_proc_read_users, NULL},
179 {"priv_msgs", S_IFREG|S_IRUGO, i2o_proc_read_priv_msgs, NULL},
180 {"authorized_users", S_IFREG|S_IRUGO, i2o_proc_read_authorized_users, NULL},
181 {"dev_identity", S_IFREG|S_IRUGO, i2o_proc_read_dev_identity, NULL},
182 {"ddm_identity", S_IFREG|S_IRUGO, i2o_proc_read_ddm_identity, NULL},
183 {"user_info", S_IFREG|S_IRUGO, i2o_proc_read_uinfo, NULL},
184 {"sgl_limits", S_IFREG|S_IRUGO, i2o_proc_read_sgl_limits, NULL},
185 {"sensors", S_IFREG|S_IRUGO, i2o_proc_read_sensors, NULL},
186 {NULL, 0, NULL, NULL}
190 * Storage unit specific entries (SCSI Periph, BS) with device names
192 static i2o_proc_entry rbs_dev_entries[] =
194 {"dev_name", S_IFREG|S_IRUGO, i2o_proc_read_dev_name, NULL},
195 {NULL, 0, NULL, NULL}
198 #define SCSI_TABLE_SIZE 13
199 static char *scsi_devices[] =
201 "Direct-Access Read/Write",
202 "Sequential-Access Storage",
208 "Optical Memory Device",
209 "Medium Changer Device",
210 "Communications Device",
211 "Graphics Art Pre-Press Device",
212 "Graphics Art Pre-Press Device",
213 "Array Controller Device"
219 * Generic LAN specific entries
221 * Should groups with r/w entries have their own subdirectory?
224 static i2o_proc_entry lan_entries[] =
226 {"lan_dev_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_dev_info, NULL},
227 {"lan_mac_addr", S_IFREG|S_IRUGO, i2o_proc_read_lan_mac_addr, NULL},
228 {"lan_mcast_addr", S_IFREG|S_IRUGO|S_IWUSR,
229 i2o_proc_read_lan_mcast_addr, NULL},
230 {"lan_batch_ctrl", S_IFREG|S_IRUGO|S_IWUSR,
231 i2o_proc_read_lan_batch_control, NULL},
232 {"lan_operation", S_IFREG|S_IRUGO, i2o_proc_read_lan_operation, NULL},
233 {"lan_media_operation", S_IFREG|S_IRUGO,
234 i2o_proc_read_lan_media_operation, NULL},
235 {"lan_alt_addr", S_IFREG|S_IRUGO, i2o_proc_read_lan_alt_addr, NULL},
236 {"lan_tx_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_tx_info, NULL},
237 {"lan_rx_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_rx_info, NULL},
239 {"lan_hist_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_hist_stats, NULL},
240 {NULL, 0, NULL, NULL}
244 * Port specific LAN entries
247 static i2o_proc_entry lan_eth_entries[] =
249 {"lan_eth_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_eth_stats, NULL},
250 {NULL, 0, NULL, NULL}
253 static i2o_proc_entry lan_tr_entries[] =
255 {"lan_tr_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_tr_stats, NULL},
256 {NULL, 0, NULL, NULL}
259 static i2o_proc_entry lan_fddi_entries[] =
261 {"lan_fddi_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_fddi_stats, NULL},
262 {NULL, 0, NULL, NULL}
266 static char *chtostr(u8 *chars, int n)
270 return strncat(tmp, (char *)chars, n);
273 static int i2o_report_query_status(char *buf, int block_status, char *group)
275 switch (block_status)
278 return sprintf(buf, "Timeout reading group %s.\n",group);
280 return sprintf(buf, "No free memory to read the table.\n");
281 case -I2O_PARAMS_STATUS_INVALID_GROUP_ID:
282 return sprintf(buf, "Group %s not supported.\n", group);
284 return sprintf(buf, "Error reading group %s. BlockStatus 0x%02X\n",
285 group, -block_status);
289 static char* bus_strings[] =
301 static spinlock_t i2o_proc_lock = SPIN_LOCK_UNLOCKED;
303 int i2o_proc_read_hrt(char *buf, char **start, off_t offset, int count,
304 int *eof, void *data)
306 struct i2o_controller *c = (struct i2o_controller *)data;
307 i2o_hrt *hrt = (i2o_hrt *)c->hrt;
311 spin_lock(&i2o_proc_lock);
317 len += sprintf(buf+len,
318 "HRT table for controller is too new a version.\n");
319 spin_unlock(&i2o_proc_lock);
323 if((hrt->num_entries * hrt->entry_len + 8) > 2048) {
324 printk(KERN_WARNING "i2o_proc: HRT does not fit into buffer\n");
325 len += sprintf(buf+len,
326 "HRT table too big to fit in buffer.\n");
327 spin_unlock(&i2o_proc_lock);
331 len += sprintf(buf+len, "HRT has %d entries of %d bytes each.\n",
332 hrt->num_entries, hrt->entry_len << 2);
334 for(i = 0; i < hrt->num_entries && len < count; i++)
336 len += sprintf(buf+len, "Entry %d:\n", i);
337 len += sprintf(buf+len, " Adapter ID: %0#10x\n",
338 hrt->hrt_entry[i].adapter_id);
339 len += sprintf(buf+len, " Controlling tid: %0#6x\n",
340 hrt->hrt_entry[i].parent_tid);
342 if(hrt->hrt_entry[i].bus_type != 0x80)
344 bus = hrt->hrt_entry[i].bus_type;
345 len += sprintf(buf+len, " %s Information\n", bus_strings[bus]);
350 len += sprintf(buf+len, " IOBase: %0#6x,",
351 hrt->hrt_entry[i].bus.local_bus.LbBaseIOPort);
352 len += sprintf(buf+len, " MemoryBase: %0#10x\n",
353 hrt->hrt_entry[i].bus.local_bus.LbBaseMemoryAddress);
357 len += sprintf(buf+len, " IOBase: %0#6x,",
358 hrt->hrt_entry[i].bus.isa_bus.IsaBaseIOPort);
359 len += sprintf(buf+len, " MemoryBase: %0#10x,",
360 hrt->hrt_entry[i].bus.isa_bus.IsaBaseMemoryAddress);
361 len += sprintf(buf+len, " CSN: %0#4x,",
362 hrt->hrt_entry[i].bus.isa_bus.CSN);
366 len += sprintf(buf+len, " IOBase: %0#6x,",
367 hrt->hrt_entry[i].bus.eisa_bus.EisaBaseIOPort);
368 len += sprintf(buf+len, " MemoryBase: %0#10x,",
369 hrt->hrt_entry[i].bus.eisa_bus.EisaBaseMemoryAddress);
370 len += sprintf(buf+len, " Slot: %0#4x,",
371 hrt->hrt_entry[i].bus.eisa_bus.EisaSlotNumber);
375 len += sprintf(buf+len, " IOBase: %0#6x,",
376 hrt->hrt_entry[i].bus.mca_bus.McaBaseIOPort);
377 len += sprintf(buf+len, " MemoryBase: %0#10x,",
378 hrt->hrt_entry[i].bus.mca_bus.McaBaseMemoryAddress);
379 len += sprintf(buf+len, " Slot: %0#4x,",
380 hrt->hrt_entry[i].bus.mca_bus.McaSlotNumber);
384 len += sprintf(buf+len, " Bus: %0#4x",
385 hrt->hrt_entry[i].bus.pci_bus.PciBusNumber);
386 len += sprintf(buf+len, " Dev: %0#4x",
387 hrt->hrt_entry[i].bus.pci_bus.PciDeviceNumber);
388 len += sprintf(buf+len, " Func: %0#4x",
389 hrt->hrt_entry[i].bus.pci_bus.PciFunctionNumber);
390 len += sprintf(buf+len, " Vendor: %0#6x",
391 hrt->hrt_entry[i].bus.pci_bus.PciVendorID);
392 len += sprintf(buf+len, " Device: %0#6x\n",
393 hrt->hrt_entry[i].bus.pci_bus.PciDeviceID);
397 len += sprintf(buf+len, " Unsupported Bus Type\n");
401 len += sprintf(buf+len, " Unknown Bus Type\n");
404 spin_unlock(&i2o_proc_lock);
409 int i2o_proc_read_lct(char *buf, char **start, off_t offset, int len,
410 int *eof, void *data)
412 struct i2o_controller *c = (struct i2o_controller*)data;
413 i2o_lct *lct = (i2o_lct *)c->lct;
417 #define BUS_TABLE_SIZE 3
418 static char *bus_ports[] =
425 spin_lock(&i2o_proc_lock);
428 entries = (lct->table_size - 3)/9;
430 len += sprintf(buf, "LCT contains %d %s\n", entries,
431 entries == 1 ? "entry" : "entries");
433 len += sprintf(buf+len, "Boot Device @ ID %d\n", lct->boot_tid);
436 sprintf(buf+len, "Current Change Indicator: %#10x\n", lct->change_ind);
438 for(i = 0; i < entries; i++)
440 len += sprintf(buf+len, "Entry %d\n", i);
441 len += sprintf(buf+len, " Class, SubClass : %s", i2o_get_class_name(lct->lct_entry[i].class_id));
444 * Classes which we'll print subclass info for
446 switch(lct->lct_entry[i].class_id & 0xFFF)
448 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
449 switch(lct->lct_entry[i].sub_class)
452 len += sprintf(buf+len, ", Direct-Access Read/Write");
456 len += sprintf(buf+len, ", WORM Drive");
460 len += sprintf(buf+len, ", CD-ROM Drive");
464 len += sprintf(buf+len, ", Optical Memory Device");
468 len += sprintf(buf+len, ", Unknown (0x%02x)",
469 lct->lct_entry[i].sub_class);
475 switch(lct->lct_entry[i].sub_class & 0xFF)
478 len += sprintf(buf+len, ", Ethernet");
482 len += sprintf(buf+len, ", 100base VG");
486 len += sprintf(buf+len, ", IEEE 802.5/Token-Ring");
490 len += sprintf(buf+len, ", ANSI X3T9.5 FDDI");
494 len += sprintf(buf+len, ", Fibre Channel");
498 len += sprintf(buf+len, ", Unknown Sub-Class (0x%02x)",
499 lct->lct_entry[i].sub_class & 0xFF);
504 case I2O_CLASS_SCSI_PERIPHERAL:
505 if(lct->lct_entry[i].sub_class < SCSI_TABLE_SIZE)
506 len += sprintf(buf+len, ", %s",
507 scsi_devices[lct->lct_entry[i].sub_class]);
509 len += sprintf(buf+len, ", Unknown Device Type");
512 case I2O_CLASS_BUS_ADAPTER_PORT:
513 if(lct->lct_entry[i].sub_class < BUS_TABLE_SIZE)
514 len += sprintf(buf+len, ", %s",
515 bus_ports[lct->lct_entry[i].sub_class]);
517 len += sprintf(buf+len, ", Unknown Bus Type");
520 len += sprintf(buf+len, "\n");
522 len += sprintf(buf+len, " Local TID : 0x%03x\n", lct->lct_entry[i].tid);
523 len += sprintf(buf+len, " User TID : 0x%03x\n", lct->lct_entry[i].user_tid);
524 len += sprintf(buf+len, " Parent TID : 0x%03x\n",
525 lct->lct_entry[i].parent_tid);
526 len += sprintf(buf+len, " Identity Tag : 0x%x%x%x%x%x%x%x%x\n",
527 lct->lct_entry[i].identity_tag[0],
528 lct->lct_entry[i].identity_tag[1],
529 lct->lct_entry[i].identity_tag[2],
530 lct->lct_entry[i].identity_tag[3],
531 lct->lct_entry[i].identity_tag[4],
532 lct->lct_entry[i].identity_tag[5],
533 lct->lct_entry[i].identity_tag[6],
534 lct->lct_entry[i].identity_tag[7]);
535 len += sprintf(buf+len, " Change Indicator : %0#10x\n",
536 lct->lct_entry[i].change_ind);
537 len += sprintf(buf+len, " Event Capab Mask : %0#10x\n",
538 lct->lct_entry[i].device_flags);
541 spin_unlock(&i2o_proc_lock);
545 int i2o_proc_read_status(char *buf, char **start, off_t offset, int len,
546 int *eof, void *data)
548 struct i2o_controller *c = (struct i2o_controller*)data;
552 spin_lock(&i2o_proc_lock);
555 i2o_status_get(c); // reread the status block
557 len += sprintf(buf+len,"Organization ID : %0#6x\n",
558 c->status_block->org_id);
560 version = c->status_block->i2o_version;
562 /* FIXME for Spec 2.0
563 if (version == 0x02) {
564 len += sprintf(buf+len,"Lowest I2O version supported: ");
565 switch(workspace[2]) {
567 len += sprintf(buf+len,"1.0\n");
570 len += sprintf(buf+len,"1.5\n");
573 len += sprintf(buf+len,"2.0\n");
577 len += sprintf(buf+len, "Highest I2O version supported: ");
578 switch(workspace[3]) {
580 len += sprintf(buf+len,"1.0\n");
583 len += sprintf(buf+len,"1.5\n");
586 len += sprintf(buf+len,"2.0\n");
591 len += sprintf(buf+len,"IOP ID : %0#5x\n",
592 c->status_block->iop_id);
593 len += sprintf(buf+len,"Host Unit ID : %0#6x\n",
594 c->status_block->host_unit_id);
595 len += sprintf(buf+len,"Segment Number : %0#5x\n",
596 c->status_block->segment_number);
598 len += sprintf(buf+len, "I2O version : ");
601 len += sprintf(buf+len,"1.0\n");
604 len += sprintf(buf+len,"1.5\n");
607 len += sprintf(buf+len,"2.0\n");
610 len += sprintf(buf+len,"Unknown version\n");
613 len += sprintf(buf+len, "IOP State : ");
614 switch (c->status_block->iop_state) {
616 len += sprintf(buf+len,"INIT\n");
620 len += sprintf(buf+len,"RESET\n");
624 len += sprintf(buf+len,"HOLD\n");
628 len += sprintf(buf+len,"READY\n");
632 len += sprintf(buf+len,"OPERATIONAL\n");
636 len += sprintf(buf+len,"FAILED\n");
640 len += sprintf(buf+len,"FAULTED\n");
644 len += sprintf(buf+len,"Unknown\n");
648 len += sprintf(buf+len,"Messenger Type : ");
649 switch (c->status_block->msg_type) {
651 len += sprintf(buf+len,"Memory mapped\n");
654 len += sprintf(buf+len,"Memory mapped only\n");
657 len += sprintf(buf+len,"Remote only\n");
660 len += sprintf(buf+len,"Memory mapped and remote\n");
663 len += sprintf(buf+len,"Unknown\n");
666 len += sprintf(buf+len,"Inbound Frame Size : %d bytes\n",
667 c->status_block->inbound_frame_size<<2);
668 len += sprintf(buf+len,"Max Inbound Frames : %d\n",
669 c->status_block->max_inbound_frames);
670 len += sprintf(buf+len,"Current Inbound Frames : %d\n",
671 c->status_block->cur_inbound_frames);
672 len += sprintf(buf+len,"Max Outbound Frames : %d\n",
673 c->status_block->max_outbound_frames);
675 /* Spec doesn't say if NULL terminated or not... */
676 memcpy(prodstr, c->status_block->product_id, 24);
678 len += sprintf(buf+len,"Product ID : %s\n", prodstr);
679 len += sprintf(buf+len,"Expected LCT Size : %d bytes\n",
680 c->status_block->expected_lct_size);
682 len += sprintf(buf+len,"IOP Capabilities\n");
683 len += sprintf(buf+len," Context Field Size Support : ");
684 switch (c->status_block->iop_capabilities & 0x0000003) {
686 len += sprintf(buf+len,"Supports only 32-bit context fields\n");
689 len += sprintf(buf+len,"Supports only 64-bit context fields\n");
692 len += sprintf(buf+len,"Supports 32-bit and 64-bit context fields, "
693 "but not concurrently\n");
696 len += sprintf(buf+len,"Supports 32-bit and 64-bit context fields "
700 len += sprintf(buf+len,"0x%08x\n",c->status_block->iop_capabilities);
702 len += sprintf(buf+len," Current Context Field Size : ");
703 switch (c->status_block->iop_capabilities & 0x0000000C) {
705 len += sprintf(buf+len,"not configured\n");
708 len += sprintf(buf+len,"Supports only 32-bit context fields\n");
711 len += sprintf(buf+len,"Supports only 64-bit context fields\n");
714 len += sprintf(buf+len,"Supports both 32-bit or 64-bit context fields "
718 len += sprintf(buf+len,"\n");
720 len += sprintf(buf+len," Inbound Peer Support : %s\n",
721 (c->status_block->iop_capabilities & 0x00000010) ? "Supported" : "Not supported");
722 len += sprintf(buf+len," Outbound Peer Support : %s\n",
723 (c->status_block->iop_capabilities & 0x00000020) ? "Supported" : "Not supported");
724 len += sprintf(buf+len," Peer to Peer Support : %s\n",
725 (c->status_block->iop_capabilities & 0x00000040) ? "Supported" : "Not supported");
727 len += sprintf(buf+len, "Desired private memory size : %d kB\n",
728 c->status_block->desired_mem_size>>10);
729 len += sprintf(buf+len, "Allocated private memory size : %d kB\n",
730 c->status_block->current_mem_size>>10);
731 len += sprintf(buf+len, "Private memory base address : %0#10x\n",
732 c->status_block->current_mem_base);
733 len += sprintf(buf+len, "Desired private I/O size : %d kB\n",
734 c->status_block->desired_io_size>>10);
735 len += sprintf(buf+len, "Allocated private I/O size : %d kB\n",
736 c->status_block->current_io_size>>10);
737 len += sprintf(buf+len, "Private I/O base address : %0#10x\n",
738 c->status_block->current_io_base);
740 spin_unlock(&i2o_proc_lock);
745 int i2o_proc_read_hw(char *buf, char **start, off_t offset, int len,
746 int *eof, void *data)
748 struct i2o_controller *c = (struct i2o_controller*)data;
749 static u32 work32[5];
750 static u8 *work8 = (u8*)work32;
751 static u16 *work16 = (u16*)work32;
755 static char *cpu_table[] =
757 "Intel 80960 series",
759 "Motorola 68000 series",
767 spin_lock(&i2o_proc_lock);
771 token = i2o_query_scalar(c, ADAPTER_TID, 0x0000, -1, &work32, sizeof(work32));
774 len += i2o_report_query_status(buf+len, token,"0x0000 IOP Hardware");
775 spin_unlock(&i2o_proc_lock);
779 len += sprintf(buf+len, "I2O Vendor ID : %0#6x\n", work16[0]);
780 len += sprintf(buf+len, "Product ID : %0#6x\n", work16[1]);
781 len += sprintf(buf+len, "CPU : ");
783 len += sprintf(buf+len, "Unknown\n");
785 len += sprintf(buf+len, "%s\n", cpu_table[work8[16]]);
786 /* Anyone using ProcessorVersion? */
788 len += sprintf(buf+len, "RAM : %dkB\n", work32[1]>>10);
789 len += sprintf(buf+len, "Non-Volatile Mem : %dkB\n", work32[2]>>10);
792 len += sprintf(buf+len, "Capabilities : 0x%08x\n", hwcap);
793 len += sprintf(buf+len, " [%s] Self booting\n",
794 (hwcap&0x00000001) ? "+" : "-");
795 len += sprintf(buf+len, " [%s] Upgradable IRTOS\n",
796 (hwcap&0x00000002) ? "+" : "-");
797 len += sprintf(buf+len, " [%s] Supports downloading DDMs\n",
798 (hwcap&0x00000004) ? "+" : "-");
799 len += sprintf(buf+len, " [%s] Supports installing DDMs\n",
800 (hwcap&0x00000008) ? "+" : "-");
801 len += sprintf(buf+len, " [%s] Battery-backed RAM\n",
802 (hwcap&0x00000010) ? "+" : "-");
804 spin_unlock(&i2o_proc_lock);
810 /* Executive group 0003h - Executing DDM List (table) */
811 int i2o_proc_read_ddm_table(char *buf, char **start, off_t offset, int len,
812 int *eof, void *data)
814 struct i2o_controller *c = (struct i2o_controller*)data;
818 typedef struct _i2o_exec_execute_ddm_table {
824 u8 module_name_version[28];
827 } i2o_exec_execute_ddm_table;
838 i2o_exec_execute_ddm_table ddm_table[MAX_I2O_MODULES];
841 i2o_exec_execute_ddm_table ddm_table;
843 result = kmalloc(sizeof(*result), GFP_KERNEL);
847 spin_lock(&i2o_proc_lock);
850 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
854 result, sizeof(*result));
857 len += i2o_report_query_status(buf+len, token,"0x0003 Executing DDM List");
861 len += sprintf(buf+len, "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n");
862 ddm_table=result->ddm_table[0];
864 for(i=0; i < result->row_count; ddm_table=result->ddm_table[++i])
866 len += sprintf(buf+len, "0x%03x ", ddm_table.ddm_tid & 0xFFF);
868 switch(ddm_table.module_type)
871 len += sprintf(buf+len, "Downloaded DDM ");
874 len += sprintf(buf+len, "Embedded DDM ");
877 len += sprintf(buf+len, " ");
880 len += sprintf(buf+len, "%-#7x", ddm_table.i2o_vendor_id);
881 len += sprintf(buf+len, "%-#8x", ddm_table.module_id);
882 len += sprintf(buf+len, "%-29s", chtostr(ddm_table.module_name_version, 28));
883 len += sprintf(buf+len, "%9d ", ddm_table.data_size);
884 len += sprintf(buf+len, "%8d", ddm_table.code_size);
886 len += sprintf(buf+len, "\n");
889 spin_unlock(&i2o_proc_lock);
895 /* Executive group 0004h - Driver Store (scalar) */
896 int i2o_proc_read_driver_store(char *buf, char **start, off_t offset, int len,
897 int *eof, void *data)
899 struct i2o_controller *c = (struct i2o_controller*)data;
903 spin_lock(&i2o_proc_lock);
907 token = i2o_query_scalar(c, ADAPTER_TID, 0x0004, -1, &work32, sizeof(work32));
909 len += i2o_report_query_status(buf+len, token,"0x0004 Driver Store");
910 spin_unlock(&i2o_proc_lock);
914 len += sprintf(buf+len, "Module limit : %d\n"
915 "Module count : %d\n"
916 "Current space : %d kB\n"
917 "Free space : %d kB\n",
918 work32[0], work32[1], work32[2]>>10, work32[3]>>10);
920 spin_unlock(&i2o_proc_lock);
926 /* Executive group 0005h - Driver Store Table (table) */
927 int i2o_proc_read_drivers_stored(char *buf, char **start, off_t offset,
928 int len, int *eof, void *data)
930 typedef struct _i2o_driver_store {
931 u16 stored_ddm_index;
936 u8 module_name_version[28];
941 } i2o_driver_store_table;
943 struct i2o_controller *c = (struct i2o_controller*)data;
956 i2o_driver_store_table dst[MAX_I2O_MODULES];
957 } i2o_driver_result_table;
959 i2o_driver_result_table *result;
960 i2o_driver_store_table *dst;
965 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
969 spin_lock(&i2o_proc_lock);
971 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
972 c, ADAPTER_TID, 0x0005, -1, NULL, 0,
973 result, sizeof(*result));
976 len += i2o_report_query_status(buf+len, token,"0x0005 DRIVER STORE TABLE");
977 spin_unlock(&i2o_proc_lock);
982 len += sprintf(buf+len, "# Module_type Vendor Mod_id Module_name Vrs"
983 "Date Mod_size Par_size Flags\n");
984 for(i=0, dst=&result->dst[0]; i < result->row_count; dst=&result->dst[++i])
986 len += sprintf(buf+len, "%-3d", dst->stored_ddm_index);
987 switch(dst->module_type)
990 len += sprintf(buf+len, "Downloaded DDM ");
993 len += sprintf(buf+len, "Embedded DDM ");
996 len += sprintf(buf+len, " ");
1000 if(c->i2oversion == 0x02)
1001 len += sprintf(buf+len, "%-d", dst->module_state);
1004 len += sprintf(buf+len, "%-#7x", dst->i2o_vendor_id);
1005 len += sprintf(buf+len, "%-#8x", dst->module_id);
1006 len += sprintf(buf+len, "%-29s", chtostr(dst->module_name_version,28));
1007 len += sprintf(buf+len, "%-9s", chtostr(dst->date,8));
1008 len += sprintf(buf+len, "%8d ", dst->module_size);
1009 len += sprintf(buf+len, "%8d ", dst->mpb_size);
1010 len += sprintf(buf+len, "0x%04x", dst->module_flags);
1012 if(c->i2oversion == 0x02)
1013 len += sprintf(buf+len, "%d",
1014 dst->notification_level);
1016 len += sprintf(buf+len, "\n");
1019 spin_unlock(&i2o_proc_lock);
1025 /* Generic group F000h - Params Descriptor (table) */
1026 int i2o_proc_read_groups(char *buf, char **start, off_t offset, int len,
1027 int *eof, void *data)
1029 struct i2o_device *d = (struct i2o_device*)data;
1034 typedef struct _i2o_group_info
1052 i2o_group_info group[256];
1055 result = kmalloc(sizeof(*result), GFP_KERNEL);
1059 spin_lock(&i2o_proc_lock);
1063 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1064 d->controller, d->lct_data.tid, 0xF000, -1, NULL, 0,
1065 result, sizeof(*result));
1068 len = i2o_report_query_status(buf+len, token, "0xF000 Params Descriptor");
1072 len += sprintf(buf+len, "# Group FieldCount RowCount Type Add Del Clear\n");
1074 for (i=0; i < result->row_count; i++)
1076 len += sprintf(buf+len, "%-3d", i);
1077 len += sprintf(buf+len, "0x%04X ", result->group[i].group_number);
1078 len += sprintf(buf+len, "%10d ", result->group[i].field_count);
1079 len += sprintf(buf+len, "%8d ", result->group[i].row_count);
1081 properties = result->group[i].properties;
1082 if (properties & 0x1) len += sprintf(buf+len, "Table ");
1083 else len += sprintf(buf+len, "Scalar ");
1084 if (properties & 0x2) len += sprintf(buf+len, " + ");
1085 else len += sprintf(buf+len, " - ");
1086 if (properties & 0x4) len += sprintf(buf+len, " + ");
1087 else len += sprintf(buf+len, " - ");
1088 if (properties & 0x8) len += sprintf(buf+len, " + ");
1089 else len += sprintf(buf+len, " - ");
1091 len += sprintf(buf+len, "\n");
1094 if (result->more_flag)
1095 len += sprintf(buf+len, "There is more...\n");
1097 spin_unlock(&i2o_proc_lock);
1103 /* Generic group F001h - Physical Device Table (table) */
1104 int i2o_proc_read_phys_device(char *buf, char **start, off_t offset, int len,
1105 int *eof, void *data)
1107 struct i2o_device *d = (struct i2o_device*)data;
1123 spin_lock(&i2o_proc_lock);
1126 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1127 d->controller, d->lct_data.tid,
1128 0xF001, -1, NULL, 0,
1129 &result, sizeof(result));
1132 len += i2o_report_query_status(buf+len, token,"0xF001 Physical Device Table");
1133 spin_unlock(&i2o_proc_lock);
1137 if (result.row_count)
1138 len += sprintf(buf+len, "# AdapterId\n");
1140 for (i=0; i < result.row_count; i++)
1142 len += sprintf(buf+len, "%-2d", i);
1143 len += sprintf(buf+len, "%#7x\n", result.adapter_id[i]);
1146 if (result.more_flag)
1147 len += sprintf(buf+len, "There is more...\n");
1149 spin_unlock(&i2o_proc_lock);
1153 /* Generic group F002h - Claimed Table (table) */
1154 int i2o_proc_read_claimed(char *buf, char **start, off_t offset, int len,
1155 int *eof, void *data)
1157 struct i2o_device *d = (struct i2o_device*)data;
1169 u16 claimed_tid[64];
1172 spin_lock(&i2o_proc_lock);
1175 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1176 d->controller, d->lct_data.tid,
1177 0xF002, -1, NULL, 0,
1178 &result, sizeof(result));
1181 len += i2o_report_query_status(buf+len, token,"0xF002 Claimed Table");
1182 spin_unlock(&i2o_proc_lock);
1186 if (result.row_count)
1187 len += sprintf(buf+len, "# ClaimedTid\n");
1189 for (i=0; i < result.row_count; i++)
1191 len += sprintf(buf+len, "%-2d", i);
1192 len += sprintf(buf+len, "%#7x\n", result.claimed_tid[i]);
1195 if (result.more_flag)
1196 len += sprintf(buf+len, "There is more...\n");
1198 spin_unlock(&i2o_proc_lock);
1202 /* Generic group F003h - User Table (table) */
1203 int i2o_proc_read_users(char *buf, char **start, off_t offset, int len,
1204 int *eof, void *data)
1206 struct i2o_device *d = (struct i2o_device*)data;
1210 typedef struct _i2o_user_table
1228 i2o_user_table user[64];
1231 result = kmalloc(sizeof(*result), GFP_KERNEL);
1235 spin_lock(&i2o_proc_lock);
1238 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1239 d->controller, d->lct_data.tid,
1240 0xF003, -1, NULL, 0,
1241 result, sizeof(*result));
1244 len += i2o_report_query_status(buf+len, token,"0xF003 User Table");
1248 len += sprintf(buf+len, "# Instance UserTid ClaimType\n");
1250 for(i=0; i < result->row_count; i++)
1252 len += sprintf(buf+len, "%-3d", i);
1253 len += sprintf(buf+len, "%#8x ", result->user[i].instance);
1254 len += sprintf(buf+len, "%#7x ", result->user[i].user_tid);
1255 len += sprintf(buf+len, "%#9x\n", result->user[i].claim_type);
1258 if (result->more_flag)
1259 len += sprintf(buf+len, "There is more...\n");
1261 spin_unlock(&i2o_proc_lock);
1266 /* Generic group F005h - Private message extensions (table) (optional) */
1267 int i2o_proc_read_priv_msgs(char *buf, char **start, off_t offset, int len,
1268 int *eof, void *data)
1270 struct i2o_device *d = (struct i2o_device*)data;
1274 typedef struct _i2o_private
1277 u16 organization_id;
1278 u16 x_function_code;
1290 i2o_private extension[64];
1293 spin_lock(&i2o_proc_lock);
1297 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1298 d->controller, d->lct_data.tid,
1301 &result, sizeof(result));
1304 len += i2o_report_query_status(buf+len, token,"0xF005 Private Message Extensions (optional)");
1305 spin_unlock(&i2o_proc_lock);
1309 len += sprintf(buf+len, "Instance# OrgId FunctionCode\n");
1311 for(i=0; i < result.row_count; i++)
1313 len += sprintf(buf+len, "%0#9x ", result.extension[i].ext_instance);
1314 len += sprintf(buf+len, "%0#6x ", result.extension[i].organization_id);
1315 len += sprintf(buf+len, "%0#6x", result.extension[i].x_function_code);
1317 len += sprintf(buf+len, "\n");
1320 if(result.more_flag)
1321 len += sprintf(buf+len, "There is more...\n");
1323 spin_unlock(&i2o_proc_lock);
1329 /* Generic group F006h - Authorized User Table (table) */
1330 int i2o_proc_read_authorized_users(char *buf, char **start, off_t offset, int len,
1331 int *eof, void *data)
1333 struct i2o_device *d = (struct i2o_device*)data;
1346 u32 alternate_tid[64];
1349 spin_lock(&i2o_proc_lock);
1352 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1353 d->controller, d->lct_data.tid,
1356 &result, sizeof(result));
1359 len += i2o_report_query_status(buf+len, token,"0xF006 Autohorized User Table");
1360 spin_unlock(&i2o_proc_lock);
1364 if (result.row_count)
1365 len += sprintf(buf+len, "# AlternateTid\n");
1367 for(i=0; i < result.row_count; i++)
1369 len += sprintf(buf+len, "%-2d", i);
1370 len += sprintf(buf+len, "%#7x ", result.alternate_tid[i]);
1373 if (result.more_flag)
1374 len += sprintf(buf+len, "There is more...\n");
1376 spin_unlock(&i2o_proc_lock);
1381 /* Generic group F100h - Device Identity (scalar) */
1382 int i2o_proc_read_dev_identity(char *buf, char **start, off_t offset, int len,
1383 int *eof, void *data)
1385 struct i2o_device *d = (struct i2o_device*)data;
1386 static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
1387 // == (allow) 512d bytes (max)
1388 static u16 *work16 = (u16*)work32;
1391 spin_lock(&i2o_proc_lock);
1395 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1397 &work32, sizeof(work32));
1400 len += i2o_report_query_status(buf+len, token ,"0xF100 Device Identity");
1401 spin_unlock(&i2o_proc_lock);
1405 len += sprintf(buf, "Device Class : %s\n", i2o_get_class_name(work16[0]));
1406 len += sprintf(buf+len, "Owner TID : %0#5x\n", work16[2]);
1407 len += sprintf(buf+len, "Parent TID : %0#5x\n", work16[3]);
1408 len += sprintf(buf+len, "Vendor info : %s\n", chtostr((u8 *)(work32+2), 16));
1409 len += sprintf(buf+len, "Product info : %s\n", chtostr((u8 *)(work32+6), 16));
1410 len += sprintf(buf+len, "Description : %s\n", chtostr((u8 *)(work32+10), 16));
1411 len += sprintf(buf+len, "Product rev. : %s\n", chtostr((u8 *)(work32+14), 8));
1413 len += sprintf(buf+len, "Serial number : ");
1414 len = print_serial_number(buf, len,
1416 /* allow for SNLen plus
1417 * possible trailing '\0'
1419 sizeof(work32)-(16*sizeof(u32))-2
1421 len += sprintf(buf+len, "\n");
1423 spin_unlock(&i2o_proc_lock);
1429 int i2o_proc_read_dev_name(char *buf, char **start, off_t offset, int len,
1430 int *eof, void *data)
1432 struct i2o_device *d = (struct i2o_device*)data;
1434 if ( d->dev_name[0] == '\0' )
1437 len = sprintf(buf, "%s\n", d->dev_name);
1443 /* Generic group F101h - DDM Identity (scalar) */
1444 int i2o_proc_read_ddm_identity(char *buf, char **start, off_t offset, int len,
1445 int *eof, void *data)
1447 struct i2o_device *d = (struct i2o_device*)data;
1456 u8 serial_number[12];
1457 u8 pad[256]; // allow up to 256 byte (max) serial number
1460 spin_lock(&i2o_proc_lock);
1464 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1466 &result, sizeof(result));
1469 len += i2o_report_query_status(buf+len, token,"0xF101 DDM Identity");
1470 spin_unlock(&i2o_proc_lock);
1474 len += sprintf(buf, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
1475 len += sprintf(buf+len, "Module name : %s\n", chtostr(result.module_name, 24));
1476 len += sprintf(buf+len, "Module revision : %s\n", chtostr(result.module_rev, 8));
1478 len += sprintf(buf+len, "Serial number : ");
1479 len = print_serial_number(buf, len, result.serial_number, sizeof(result)-36);
1480 /* allow for SNLen plus possible trailing '\0' */
1482 len += sprintf(buf+len, "\n");
1484 spin_unlock(&i2o_proc_lock);
1489 /* Generic group F102h - User Information (scalar) */
1490 int i2o_proc_read_uinfo(char *buf, char **start, off_t offset, int len,
1491 int *eof, void *data)
1493 struct i2o_device *d = (struct i2o_device*)data;
1499 u8 service_name[64];
1500 u8 physical_location[64];
1501 u8 instance_number[4];
1504 spin_lock(&i2o_proc_lock);
1507 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1509 &result, sizeof(result));
1512 len += i2o_report_query_status(buf+len, token,"0xF102 User Information");
1513 spin_unlock(&i2o_proc_lock);
1517 len += sprintf(buf, "Device name : %s\n", chtostr(result.device_name, 64));
1518 len += sprintf(buf+len, "Service name : %s\n", chtostr(result.service_name, 64));
1519 len += sprintf(buf+len, "Physical name : %s\n", chtostr(result.physical_location, 64));
1520 len += sprintf(buf+len, "Instance number : %s\n", chtostr(result.instance_number, 4));
1522 spin_unlock(&i2o_proc_lock);
1526 /* Generic group F103h - SGL Operating Limits (scalar) */
1527 int i2o_proc_read_sgl_limits(char *buf, char **start, off_t offset, int len,
1528 int *eof, void *data)
1530 struct i2o_device *d = (struct i2o_device*)data;
1531 static u32 work32[12];
1532 static u16 *work16 = (u16 *)work32;
1533 static u8 *work8 = (u8 *)work32;
1536 spin_lock(&i2o_proc_lock);
1540 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1542 &work32, sizeof(work32));
1545 len += i2o_report_query_status(buf+len, token,"0xF103 SGL Operating Limits");
1546 spin_unlock(&i2o_proc_lock);
1550 len += sprintf(buf, "SGL chain size : %d\n", work32[0]);
1551 len += sprintf(buf+len, "Max SGL chain size : %d\n", work32[1]);
1552 len += sprintf(buf+len, "SGL chain size target : %d\n", work32[2]);
1553 len += sprintf(buf+len, "SGL frag count : %d\n", work16[6]);
1554 len += sprintf(buf+len, "Max SGL frag count : %d\n", work16[7]);
1555 len += sprintf(buf+len, "SGL frag count target : %d\n", work16[8]);
1557 if (d->i2oversion == 0x02)
1559 len += sprintf(buf+len, "SGL data alignment : %d\n", work16[8]);
1560 len += sprintf(buf+len, "SGL addr limit : %d\n", work8[20]);
1561 len += sprintf(buf+len, "SGL addr sizes supported : ");
1562 if (work8[21] & 0x01)
1563 len += sprintf(buf+len, "32 bit ");
1564 if (work8[21] & 0x02)
1565 len += sprintf(buf+len, "64 bit ");
1566 if (work8[21] & 0x04)
1567 len += sprintf(buf+len, "96 bit ");
1568 if (work8[21] & 0x08)
1569 len += sprintf(buf+len, "128 bit ");
1570 len += sprintf(buf+len, "\n");
1573 spin_unlock(&i2o_proc_lock);
1578 /* Generic group F200h - Sensors (scalar) */
1579 int i2o_proc_read_sensors(char *buf, char **start, off_t offset, int len,
1580 int *eof, void *data)
1582 struct i2o_device *d = (struct i2o_device*)data;
1587 u16 sensor_instance;
1589 u16 component_instance;
1592 u8 scaling_exponent;
1594 u32 minimum_reading;
1595 u32 low2lowcat_treshold;
1596 u32 lowcat2low_treshold;
1597 u32 lowwarn2low_treshold;
1598 u32 low2lowwarn_treshold;
1599 u32 norm2lowwarn_treshold;
1600 u32 lowwarn2norm_treshold;
1601 u32 nominal_reading;
1602 u32 hiwarn2norm_treshold;
1603 u32 norm2hiwarn_treshold;
1604 u32 high2hiwarn_treshold;
1605 u32 hiwarn2high_treshold;
1606 u32 hicat2high_treshold;
1607 u32 hi2hicat_treshold;
1608 u32 maximum_reading;
1613 spin_lock(&i2o_proc_lock);
1616 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1618 &result, sizeof(result));
1621 len += i2o_report_query_status(buf+len, token,"0xF200 Sensors (optional)");
1622 spin_unlock(&i2o_proc_lock);
1626 len += sprintf(buf+len, "Sensor instance : %d\n", result.sensor_instance);
1628 len += sprintf(buf+len, "Component : %d = ", result.component);
1629 switch (result.component)
1631 case 0: len += sprintf(buf+len, "Other");
1633 case 1: len += sprintf(buf+len, "Planar logic Board");
1635 case 2: len += sprintf(buf+len, "CPU");
1637 case 3: len += sprintf(buf+len, "Chassis");
1639 case 4: len += sprintf(buf+len, "Power Supply");
1641 case 5: len += sprintf(buf+len, "Storage");
1643 case 6: len += sprintf(buf+len, "External");
1646 len += sprintf(buf+len,"\n");
1648 len += sprintf(buf+len, "Component instance : %d\n", result.component_instance);
1649 len += sprintf(buf+len, "Sensor class : %s\n",
1650 result.sensor_class ? "Analog" : "Digital");
1652 len += sprintf(buf+len, "Sensor type : %d = ",result.sensor_type);
1653 switch (result.sensor_type)
1655 case 0: len += sprintf(buf+len, "Other\n");
1657 case 1: len += sprintf(buf+len, "Thermal\n");
1659 case 2: len += sprintf(buf+len, "DC voltage (DC volts)\n");
1661 case 3: len += sprintf(buf+len, "AC voltage (AC volts)\n");
1663 case 4: len += sprintf(buf+len, "DC current (DC amps)\n");
1665 case 5: len += sprintf(buf+len, "AC current (AC volts)\n");
1667 case 6: len += sprintf(buf+len, "Door open\n");
1669 case 7: len += sprintf(buf+len, "Fan operational\n");
1673 len += sprintf(buf+len, "Scaling exponent : %d\n", result.scaling_exponent);
1674 len += sprintf(buf+len, "Actual reading : %d\n", result.actual_reading);
1675 len += sprintf(buf+len, "Minimum reading : %d\n", result.minimum_reading);
1676 len += sprintf(buf+len, "Low2LowCat treshold : %d\n", result.low2lowcat_treshold);
1677 len += sprintf(buf+len, "LowCat2Low treshold : %d\n", result.lowcat2low_treshold);
1678 len += sprintf(buf+len, "LowWarn2Low treshold : %d\n", result.lowwarn2low_treshold);
1679 len += sprintf(buf+len, "Low2LowWarn treshold : %d\n", result.low2lowwarn_treshold);
1680 len += sprintf(buf+len, "Norm2LowWarn treshold : %d\n", result.norm2lowwarn_treshold);
1681 len += sprintf(buf+len, "LowWarn2Norm treshold : %d\n", result.lowwarn2norm_treshold);
1682 len += sprintf(buf+len, "Nominal reading : %d\n", result.nominal_reading);
1683 len += sprintf(buf+len, "HiWarn2Norm treshold : %d\n", result.hiwarn2norm_treshold);
1684 len += sprintf(buf+len, "Norm2HiWarn treshold : %d\n", result.norm2hiwarn_treshold);
1685 len += sprintf(buf+len, "High2HiWarn treshold : %d\n", result.high2hiwarn_treshold);
1686 len += sprintf(buf+len, "HiWarn2High treshold : %d\n", result.hiwarn2high_treshold);
1687 len += sprintf(buf+len, "HiCat2High treshold : %d\n", result.hicat2high_treshold);
1688 len += sprintf(buf+len, "High2HiCat treshold : %d\n", result.hi2hicat_treshold);
1689 len += sprintf(buf+len, "Maximum reading : %d\n", result.maximum_reading);
1691 len += sprintf(buf+len, "Sensor state : %d = ", result.sensor_state);
1692 switch (result.sensor_state)
1694 case 0: len += sprintf(buf+len, "Normal\n");
1696 case 1: len += sprintf(buf+len, "Abnormal\n");
1698 case 2: len += sprintf(buf+len, "Unknown\n");
1700 case 3: len += sprintf(buf+len, "Low Catastrophic (LoCat)\n");
1702 case 4: len += sprintf(buf+len, "Low (Low)\n");
1704 case 5: len += sprintf(buf+len, "Low Warning (LoWarn)\n");
1706 case 6: len += sprintf(buf+len, "High Warning (HiWarn)\n");
1708 case 7: len += sprintf(buf+len, "High (High)\n");
1710 case 8: len += sprintf(buf+len, "High Catastrophic (HiCat)\n");
1714 len += sprintf(buf+len, "Event_enable : 0x%02X\n", result.event_enable);
1715 len += sprintf(buf+len, " [%s] Operational state change. \n",
1716 (result.event_enable & 0x01) ? "+" : "-" );
1717 len += sprintf(buf+len, " [%s] Low catastrophic. \n",
1718 (result.event_enable & 0x02) ? "+" : "-" );
1719 len += sprintf(buf+len, " [%s] Low reading. \n",
1720 (result.event_enable & 0x04) ? "+" : "-" );
1721 len += sprintf(buf+len, " [%s] Low warning. \n",
1722 (result.event_enable & 0x08) ? "+" : "-" );
1723 len += sprintf(buf+len, " [%s] Change back to normal from out of range state. \n",
1724 (result.event_enable & 0x10) ? "+" : "-" );
1725 len += sprintf(buf+len, " [%s] High warning. \n",
1726 (result.event_enable & 0x20) ? "+" : "-" );
1727 len += sprintf(buf+len, " [%s] High reading. \n",
1728 (result.event_enable & 0x40) ? "+" : "-" );
1729 len += sprintf(buf+len, " [%s] High catastrophic. \n",
1730 (result.event_enable & 0x80) ? "+" : "-" );
1732 spin_unlock(&i2o_proc_lock);
1737 static int print_serial_number(char *buff, int pos, u8 *serialno, int max_len)
1741 /* 19990419 -sralston
1742 * The I2O v1.5 (and v2.0 so far) "official specification"
1743 * got serial numbers WRONG!
1744 * Apparently, and despite what Section 3.4.4 says and
1745 * Figure 3-35 shows (pg 3-39 in the pdf doc),
1746 * the convention / consensus seems to be:
1747 * + First byte is SNFormat
1748 * + Second byte is SNLen (but only if SNFormat==7 (?))
1749 * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
1753 case I2O_SNFORMAT_BINARY: /* Binary */
1754 pos += sprintf(buff+pos, "0x");
1755 for(i = 0; i < serialno[1]; i++)
1757 pos += sprintf(buff+pos, "%02X", serialno[2+i]);
1761 case I2O_SNFORMAT_ASCII: /* ASCII */
1762 if ( serialno[1] < ' ' ) /* printable or SNLen? */
1765 max_len = (max_len < serialno[1]) ? max_len : serialno[1];
1766 serialno[1+max_len] = '\0';
1769 pos += sprintf(buff+pos, "%s", &serialno[2]);
1773 /* print chars for specified length */
1774 for(i = 0; i < serialno[1]; i++)
1776 pos += sprintf(buff+pos, "%c", serialno[2+i]);
1781 case I2O_SNFORMAT_UNICODE: /* UNICODE */
1782 pos += sprintf(buff+pos, "UNICODE Format. Can't Display\n");
1785 case I2O_SNFORMAT_LAN48_MAC: /* LAN-48 MAC Address */
1786 pos += sprintf(buff+pos,
1787 "LAN-48 MAC address @ %02X:%02X:%02X:%02X:%02X:%02X",
1788 serialno[2], serialno[3],
1789 serialno[4], serialno[5],
1790 serialno[6], serialno[7]);
1793 case I2O_SNFORMAT_WAN: /* WAN MAC Address */
1794 /* FIXME: Figure out what a WAN access address looks like?? */
1795 pos += sprintf(buff+pos, "WAN Access Address");
1798 /* plus new in v2.0 */
1799 case I2O_SNFORMAT_LAN64_MAC: /* LAN-64 MAC Address */
1800 /* FIXME: Figure out what a LAN-64 address really looks like?? */
1801 pos += sprintf(buff+pos,
1802 "LAN-64 MAC address @ [?:%02X:%02X:?] %02X:%02X:%02X:%02X:%02X:%02X",
1803 serialno[8], serialno[9],
1804 serialno[2], serialno[3],
1805 serialno[4], serialno[5],
1806 serialno[6], serialno[7]);
1810 case I2O_SNFORMAT_DDM: /* I2O DDM */
1811 pos += sprintf(buff+pos,
1812 "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
1813 *(u16*)&serialno[2],
1814 *(u16*)&serialno[4],
1815 *(u16*)&serialno[6]);
1818 case I2O_SNFORMAT_IEEE_REG64: /* IEEE Registered (64-bit) */
1819 case I2O_SNFORMAT_IEEE_REG128: /* IEEE Registered (128-bit) */
1820 /* FIXME: Figure if this is even close?? */
1821 pos += sprintf(buff+pos,
1822 "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n",
1823 *(u32*)&serialno[2],
1824 *(u32*)&serialno[6],
1825 *(u32*)&serialno[10],
1826 *(u32*)&serialno[14]);
1830 case I2O_SNFORMAT_UNKNOWN: /* Unknown 0 */
1831 case I2O_SNFORMAT_UNKNOWN2: /* Unknown 0xff */
1833 pos += sprintf(buff+pos, "Unknown data format (0x%02x)",
1841 const char * i2o_get_connector_type(int conn)
1844 static char *i2o_connector_type[] = {
1915 return i2o_connector_type[idx];
1919 const char * i2o_get_connection_type(int conn)
1922 static char *i2o_connection_type[] = {
1956 case I2O_LAN_UNKNOWN:
1962 case I2O_LAN_10BASE5:
1968 case I2O_LAN_10BASE2:
1971 case I2O_LAN_10BROAD36:
1974 case I2O_LAN_10BASE_T:
1977 case I2O_LAN_10BASE_FP:
1980 case I2O_LAN_10BASE_FB:
1983 case I2O_LAN_10BASE_FL:
1986 case I2O_LAN_100BASE_TX:
1989 case I2O_LAN_100BASE_FX:
1992 case I2O_LAN_100BASE_T4:
1995 case I2O_LAN_1000BASE_SX:
1998 case I2O_LAN_1000BASE_LX:
2001 case I2O_LAN_1000BASE_CX:
2004 case I2O_LAN_1000BASE_T:
2007 case I2O_LAN_100VG_ETHERNET:
2010 case I2O_LAN_100VG_TR:
2016 case I2O_LAN_16MBIT:
2019 case I2O_LAN_125MBAUD:
2022 case I2O_LAN_POINT_POINT:
2025 case I2O_LAN_ARB_LOOP:
2028 case I2O_LAN_PUBLIC_LOOP:
2031 case I2O_LAN_FABRIC:
2034 case I2O_LAN_EMULATION:
2040 case I2O_LAN_DEFAULT:
2045 return i2o_connection_type[idx];
2049 /* LAN group 0000h - Device info (scalar) */
2050 int i2o_proc_read_lan_dev_info(char *buf, char **start, off_t offset, int len,
2051 int *eof, void *data)
2053 struct i2o_device *d = (struct i2o_device*)data;
2054 static u32 work32[56];
2055 static u8 *work8 = (u8*)work32;
2056 static u16 *work16 = (u16*)work32;
2057 static u64 *work64 = (u64*)work32;
2060 spin_lock(&i2o_proc_lock);
2063 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2064 0x0000, -1, &work32, 56*4);
2066 len += i2o_report_query_status(buf+len, token, "0x0000 LAN Device Info");
2067 spin_unlock(&i2o_proc_lock);
2071 len += sprintf(buf, "LAN Type : ");
2075 len += sprintf(buf+len, "Ethernet, ");
2078 len += sprintf(buf+len, "100Base VG, ");
2081 len += sprintf(buf+len, "Token Ring, ");
2084 len += sprintf(buf+len, "FDDI, ");
2087 len += sprintf(buf+len, "Fibre Channel, ");
2090 len += sprintf(buf+len, "Unknown type (0x%04x), ", work16[0]);
2094 if (work16[1]&0x00000001)
2095 len += sprintf(buf+len, "emulated LAN, ");
2097 len += sprintf(buf+len, "physical LAN port, ");
2099 if (work16[1]&0x00000002)
2100 len += sprintf(buf+len, "full duplex\n");
2102 len += sprintf(buf+len, "simplex\n");
2104 len += sprintf(buf+len, "Address format : ");
2107 len += sprintf(buf+len, "IEEE 48bit\n");
2110 len += sprintf(buf+len, "FC IEEE\n");
2113 len += sprintf(buf+len, "Unknown (0x%02x)\n", work8[4]);
2117 len += sprintf(buf+len, "State : ");
2121 len += sprintf(buf+len, "Unknown\n");
2124 len += sprintf(buf+len, "Unclaimed\n");
2127 len += sprintf(buf+len, "Operational\n");
2130 len += sprintf(buf+len, "Suspended\n");
2133 len += sprintf(buf+len, "Resetting\n");
2136 len += sprintf(buf+len, "ERROR: ");
2137 if(work16[3]&0x0001)
2138 len += sprintf(buf+len, "TxCU inoperative ");
2139 if(work16[3]&0x0002)
2140 len += sprintf(buf+len, "RxCU inoperative ");
2141 if(work16[3]&0x0004)
2142 len += sprintf(buf+len, "Local mem alloc ");
2143 len += sprintf(buf+len, "\n");
2146 len += sprintf(buf+len, "Operational no Rx\n");
2149 len += sprintf(buf+len, "Suspended no Rx\n");
2152 len += sprintf(buf+len, "Unspecified\n");
2156 len += sprintf(buf+len, "Min packet size : %d\n", work32[2]);
2157 len += sprintf(buf+len, "Max packet size : %d\n", work32[3]);
2158 len += sprintf(buf+len, "HW address : "
2159 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2160 work8[16],work8[17],work8[18],work8[19],
2161 work8[20],work8[21],work8[22],work8[23]);
2163 len += sprintf(buf+len, "Max Tx wire speed : %d bps\n", (int)work64[3]);
2164 len += sprintf(buf+len, "Max Rx wire speed : %d bps\n", (int)work64[4]);
2166 len += sprintf(buf+len, "Min SDU packet size : 0x%08x\n", work32[10]);
2167 len += sprintf(buf+len, "Max SDU packet size : 0x%08x\n", work32[11]);
2169 spin_unlock(&i2o_proc_lock);
2173 /* LAN group 0001h - MAC address table (scalar) */
2174 int i2o_proc_read_lan_mac_addr(char *buf, char **start, off_t offset, int len,
2175 int *eof, void *data)
2177 struct i2o_device *d = (struct i2o_device*)data;
2178 static u32 work32[48];
2179 static u8 *work8 = (u8*)work32;
2182 spin_lock(&i2o_proc_lock);
2185 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2186 0x0001, -1, &work32, 48*4);
2188 len += i2o_report_query_status(buf+len, token,"0x0001 LAN MAC Address");
2189 spin_unlock(&i2o_proc_lock);
2193 len += sprintf(buf, "Active address : "
2194 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2195 work8[0],work8[1],work8[2],work8[3],
2196 work8[4],work8[5],work8[6],work8[7]);
2197 len += sprintf(buf+len, "Current address : "
2198 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2199 work8[8],work8[9],work8[10],work8[11],
2200 work8[12],work8[13],work8[14],work8[15]);
2201 len += sprintf(buf+len, "Functional address mask : "
2202 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2203 work8[16],work8[17],work8[18],work8[19],
2204 work8[20],work8[21],work8[22],work8[23]);
2206 len += sprintf(buf+len,"HW/DDM capabilities : 0x%08x\n", work32[7]);
2207 len += sprintf(buf+len," [%s] Unicast packets supported\n",
2208 (work32[7]&0x00000001)?"+":"-");
2209 len += sprintf(buf+len," [%s] Promiscuous mode supported\n",
2210 (work32[7]&0x00000002)?"+":"-");
2211 len += sprintf(buf+len," [%s] Promiscuous multicast mode supported\n",
2212 (work32[7]&0x00000004)?"+":"-");
2213 len += sprintf(buf+len," [%s] Broadcast reception disabling supported\n",
2214 (work32[7]&0x00000100)?"+":"-");
2215 len += sprintf(buf+len," [%s] Multicast reception disabling supported\n",
2216 (work32[7]&0x00000200)?"+":"-");
2217 len += sprintf(buf+len," [%s] Functional address disabling supported\n",
2218 (work32[7]&0x00000400)?"+":"-");
2219 len += sprintf(buf+len," [%s] MAC reporting supported\n",
2220 (work32[7]&0x00000800)?"+":"-");
2222 len += sprintf(buf+len,"Filter mask : 0x%08x\n", work32[6]);
2223 len += sprintf(buf+len," [%s] Unicast packets disable\n",
2224 (work32[6]&0x00000001)?"+":"-");
2225 len += sprintf(buf+len," [%s] Promiscuous mode enable\n",
2226 (work32[6]&0x00000002)?"+":"-");
2227 len += sprintf(buf+len," [%s] Promiscuous multicast mode enable\n",
2228 (work32[6]&0x00000004)?"+":"-");
2229 len += sprintf(buf+len," [%s] Broadcast packets disable\n",
2230 (work32[6]&0x00000100)?"+":"-");
2231 len += sprintf(buf+len," [%s] Multicast packets disable\n",
2232 (work32[6]&0x00000200)?"+":"-");
2233 len += sprintf(buf+len," [%s] Functional address disable\n",
2234 (work32[6]&0x00000400)?"+":"-");
2236 if (work32[7]&0x00000800) {
2237 len += sprintf(buf+len, " MAC reporting mode : ");
2238 if (work32[6]&0x00000800)
2239 len += sprintf(buf+len, "Pass only priority MAC packets to user\n");
2240 else if (work32[6]&0x00001000)
2241 len += sprintf(buf+len, "Pass all MAC packets to user\n");
2242 else if (work32[6]&0x00001800)
2243 len += sprintf(buf+len, "Pass all MAC packets (promiscuous) to user\n");
2245 len += sprintf(buf+len, "Do not pass MAC packets to user\n");
2247 len += sprintf(buf+len, "Number of multicast addresses : %d\n", work32[8]);
2248 len += sprintf(buf+len, "Perfect filtering for max %d multicast addresses\n",
2250 len += sprintf(buf+len, "Imperfect filtering for max %d multicast addresses\n",
2253 spin_unlock(&i2o_proc_lock);
2258 /* LAN group 0002h - Multicast MAC address table (table) */
2259 int i2o_proc_read_lan_mcast_addr(char *buf, char **start, off_t offset,
2260 int len, int *eof, void *data)
2262 struct i2o_device *d = (struct i2o_device*)data;
2279 result = kmalloc(sizeof(*result), GFP_KERNEL);
2283 spin_lock(&i2o_proc_lock);
2286 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
2287 d->controller, d->lct_data.tid, 0x0002, -1,
2288 NULL, 0, result, sizeof(*result));
2291 len += i2o_report_query_status(buf+len, token,"0x002 LAN Multicast MAC Address");
2295 for (i = 0; i < result->row_count; i++)
2297 memcpy(mc_addr, result->mc_addr[i], 8);
2299 len += sprintf(buf+len, "MC MAC address[%d]: "
2300 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2301 i, mc_addr[0], mc_addr[1], mc_addr[2],
2302 mc_addr[3], mc_addr[4], mc_addr[5],
2303 mc_addr[6], mc_addr[7]);
2306 spin_unlock(&i2o_proc_lock);
2311 /* LAN group 0003h - Batch Control (scalar) */
2312 int i2o_proc_read_lan_batch_control(char *buf, char **start, off_t offset,
2313 int len, int *eof, void *data)
2315 struct i2o_device *d = (struct i2o_device*)data;
2316 static u32 work32[9];
2319 spin_lock(&i2o_proc_lock);
2322 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2323 0x0003, -1, &work32, 9*4);
2325 len += i2o_report_query_status(buf+len, token,"0x0003 LAN Batch Control");
2326 spin_unlock(&i2o_proc_lock);
2330 len += sprintf(buf, "Batch mode ");
2331 if (work32[0]&0x00000001)
2332 len += sprintf(buf+len, "disabled");
2334 len += sprintf(buf+len, "enabled");
2335 if (work32[0]&0x00000002)
2336 len += sprintf(buf+len, " (current setting)");
2337 if (work32[0]&0x00000004)
2338 len += sprintf(buf+len, ", forced");
2340 len += sprintf(buf+len, ", toggle");
2341 len += sprintf(buf+len, "\n");
2343 len += sprintf(buf+len, "Max Rx batch count : %d\n", work32[5]);
2344 len += sprintf(buf+len, "Max Rx batch delay : %d\n", work32[6]);
2345 len += sprintf(buf+len, "Max Tx batch delay : %d\n", work32[7]);
2346 len += sprintf(buf+len, "Max Tx batch count : %d\n", work32[8]);
2348 spin_unlock(&i2o_proc_lock);
2352 /* LAN group 0004h - LAN Operation (scalar) */
2353 int i2o_proc_read_lan_operation(char *buf, char **start, off_t offset, int len,
2354 int *eof, void *data)
2356 struct i2o_device *d = (struct i2o_device*)data;
2357 static u32 work32[5];
2360 spin_lock(&i2o_proc_lock);
2363 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2364 0x0004, -1, &work32, 20);
2366 len += i2o_report_query_status(buf+len, token,"0x0004 LAN Operation");
2367 spin_unlock(&i2o_proc_lock);
2371 len += sprintf(buf, "Packet prepadding (32b words) : %d\n", work32[0]);
2372 len += sprintf(buf+len, "Transmission error reporting : %s\n",
2373 (work32[1]&1)?"on":"off");
2374 len += sprintf(buf+len, "Bad packet handling : %s\n",
2375 (work32[1]&0x2)?"by host":"by DDM");
2376 len += sprintf(buf+len, "Packet orphan limit : %d\n", work32[2]);
2378 len += sprintf(buf+len, "Tx modes : 0x%08x\n", work32[3]);
2379 len += sprintf(buf+len, " [%s] HW CRC suppression\n",
2380 (work32[3]&0x00000004) ? "+" : "-");
2381 len += sprintf(buf+len, " [%s] HW IPv4 checksum\n",
2382 (work32[3]&0x00000100) ? "+" : "-");
2383 len += sprintf(buf+len, " [%s] HW TCP checksum\n",
2384 (work32[3]&0x00000200) ? "+" : "-");
2385 len += sprintf(buf+len, " [%s] HW UDP checksum\n",
2386 (work32[3]&0x00000400) ? "+" : "-");
2387 len += sprintf(buf+len, " [%s] HW RSVP checksum\n",
2388 (work32[3]&0x00000800) ? "+" : "-");
2389 len += sprintf(buf+len, " [%s] HW ICMP checksum\n",
2390 (work32[3]&0x00001000) ? "+" : "-");
2391 len += sprintf(buf+len, " [%s] Loopback suppression enable\n",
2392 (work32[3]&0x00002000) ? "+" : "-");
2394 len += sprintf(buf+len, "Rx modes : 0x%08x\n", work32[4]);
2395 len += sprintf(buf+len, " [%s] FCS in payload\n",
2396 (work32[4]&0x00000004) ? "+" : "-");
2397 len += sprintf(buf+len, " [%s] HW IPv4 checksum validation\n",
2398 (work32[4]&0x00000100) ? "+" : "-");
2399 len += sprintf(buf+len, " [%s] HW TCP checksum validation\n",
2400 (work32[4]&0x00000200) ? "+" : "-");
2401 len += sprintf(buf+len, " [%s] HW UDP checksum validation\n",
2402 (work32[4]&0x00000400) ? "+" : "-");
2403 len += sprintf(buf+len, " [%s] HW RSVP checksum validation\n",
2404 (work32[4]&0x00000800) ? "+" : "-");
2405 len += sprintf(buf+len, " [%s] HW ICMP checksum validation\n",
2406 (work32[4]&0x00001000) ? "+" : "-");
2408 spin_unlock(&i2o_proc_lock);
2412 /* LAN group 0005h - Media operation (scalar) */
2413 int i2o_proc_read_lan_media_operation(char *buf, char **start, off_t offset,
2414 int len, int *eof, void *data)
2416 struct i2o_device *d = (struct i2o_device*)data;
2422 u32 connection_type;
2423 u64 current_tx_wire_speed;
2424 u64 current_rx_wire_speed;
2428 u8 duplex_mode_target;
2429 u32 connector_type_target;
2430 u32 connection_type_target;
2433 spin_lock(&i2o_proc_lock);
2436 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2437 0x0005, -1, &result, sizeof(result));
2439 len += i2o_report_query_status(buf+len, token, "0x0005 LAN Media Operation");
2440 spin_unlock(&i2o_proc_lock);
2444 len += sprintf(buf, "Connector type : %s\n",
2445 i2o_get_connector_type(result.connector_type));
2446 len += sprintf(buf+len, "Connection type : %s\n",
2447 i2o_get_connection_type(result.connection_type));
2449 len += sprintf(buf+len, "Current Tx wire speed : %d bps\n", (int)result.current_tx_wire_speed);
2450 len += sprintf(buf+len, "Current Rx wire speed : %d bps\n", (int)result.current_rx_wire_speed);
2451 len += sprintf(buf+len, "Duplex mode : %s duplex\n",
2452 (result.duplex_mode)?"Full":"Half");
2454 len += sprintf(buf+len, "Link status : ");
2455 switch (result.link_status)
2458 len += sprintf(buf+len, "Unknown\n");
2461 len += sprintf(buf+len, "Normal\n");
2464 len += sprintf(buf+len, "Failure\n");
2467 len += sprintf(buf+len, "Reset\n");
2470 len += sprintf(buf+len, "Unspecified\n");
2473 len += sprintf(buf+len, "Duplex mode target : ");
2474 switch (result.duplex_mode_target){
2476 len += sprintf(buf+len, "Half duplex\n");
2479 len += sprintf(buf+len, "Full duplex\n");
2482 len += sprintf(buf+len, "\n");
2485 len += sprintf(buf+len, "Connector type target : %s\n",
2486 i2o_get_connector_type(result.connector_type_target));
2487 len += sprintf(buf+len, "Connection type target : %s\n",
2488 i2o_get_connection_type(result.connection_type_target));
2490 spin_unlock(&i2o_proc_lock);
2494 /* LAN group 0006h - Alternate address (table) (optional) */
2495 int i2o_proc_read_lan_alt_addr(char *buf, char **start, off_t offset, int len,
2496 int *eof, void *data)
2498 struct i2o_device *d = (struct i2o_device*)data;
2511 u8 alt_addr[256][8];
2514 result = kmalloc(sizeof(*result), GFP_KERNEL);
2518 spin_lock(&i2o_proc_lock);
2521 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
2522 d->controller, d->lct_data.tid,
2523 0x0006, -1, NULL, 0, result, sizeof(*result));
2526 len += i2o_report_query_status(buf+len, token, "0x0006 LAN Alternate Address (optional)");
2530 for (i=0; i < result->row_count; i++)
2532 memcpy(alt_addr,result->alt_addr[i],8);
2533 len += sprintf(buf+len, "Alternate address[%d]: "
2534 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2535 i, alt_addr[0], alt_addr[1], alt_addr[2],
2536 alt_addr[3], alt_addr[4], alt_addr[5],
2537 alt_addr[6], alt_addr[7]);
2540 spin_unlock(&i2o_proc_lock);
2546 /* LAN group 0007h - Transmit info (scalar) */
2547 int i2o_proc_read_lan_tx_info(char *buf, char **start, off_t offset, int len,
2548 int *eof, void *data)
2550 struct i2o_device *d = (struct i2o_device*)data;
2551 static u32 work32[8];
2554 spin_lock(&i2o_proc_lock);
2557 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2558 0x0007, -1, &work32, 8*4);
2560 len += i2o_report_query_status(buf+len, token,"0x0007 LAN Transmit Info");
2561 spin_unlock(&i2o_proc_lock);
2565 len += sprintf(buf, "Tx Max SG elements per packet : %d\n", work32[0]);
2566 len += sprintf(buf+len, "Tx Max SG elements per chain : %d\n", work32[1]);
2567 len += sprintf(buf+len, "Tx Max outstanding packets : %d\n", work32[2]);
2568 len += sprintf(buf+len, "Tx Max packets per request : %d\n", work32[3]);
2570 len += sprintf(buf+len, "Tx modes : 0x%08x\n", work32[4]);
2571 len += sprintf(buf+len, " [%s] No DA in SGL\n",
2572 (work32[4]&0x00000002) ? "+" : "-");
2573 len += sprintf(buf+len, " [%s] CRC suppression\n",
2574 (work32[4]&0x00000004) ? "+" : "-");
2575 len += sprintf(buf+len, " [%s] MAC insertion\n",
2576 (work32[4]&0x00000010) ? "+" : "-");
2577 len += sprintf(buf+len, " [%s] RIF insertion\n",
2578 (work32[4]&0x00000020) ? "+" : "-");
2579 len += sprintf(buf+len, " [%s] IPv4 checksum generation\n",
2580 (work32[4]&0x00000100) ? "+" : "-");
2581 len += sprintf(buf+len, " [%s] TCP checksum generation\n",
2582 (work32[4]&0x00000200) ? "+" : "-");
2583 len += sprintf(buf+len, " [%s] UDP checksum generation\n",
2584 (work32[4]&0x00000400) ? "+" : "-");
2585 len += sprintf(buf+len, " [%s] RSVP checksum generation\n",
2586 (work32[4]&0x00000800) ? "+" : "-");
2587 len += sprintf(buf+len, " [%s] ICMP checksum generation\n",
2588 (work32[4]&0x00001000) ? "+" : "-");
2589 len += sprintf(buf+len, " [%s] Loopback enabled\n",
2590 (work32[4]&0x00010000) ? "+" : "-");
2591 len += sprintf(buf+len, " [%s] Loopback suppression enabled\n",
2592 (work32[4]&0x00020000) ? "+" : "-");
2594 spin_unlock(&i2o_proc_lock);
2598 /* LAN group 0008h - Receive info (scalar) */
2599 int i2o_proc_read_lan_rx_info(char *buf, char **start, off_t offset, int len,
2600 int *eof, void *data)
2602 struct i2o_device *d = (struct i2o_device*)data;
2603 static u32 work32[8];
2606 spin_lock(&i2o_proc_lock);
2609 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2610 0x0008, -1, &work32, 8*4);
2612 len += i2o_report_query_status(buf+len, token,"0x0008 LAN Receive Info");
2613 spin_unlock(&i2o_proc_lock);
2617 len += sprintf(buf ,"Rx Max size of chain element : %d\n", work32[0]);
2618 len += sprintf(buf+len, "Rx Max Buckets : %d\n", work32[1]);
2619 len += sprintf(buf+len, "Rx Max Buckets in Reply : %d\n", work32[3]);
2620 len += sprintf(buf+len, "Rx Max Packets in Bucket : %d\n", work32[4]);
2621 len += sprintf(buf+len, "Rx Max Buckets in Post : %d\n", work32[5]);
2623 len += sprintf(buf+len, "Rx Modes : 0x%08x\n", work32[2]);
2624 len += sprintf(buf+len, " [%s] FCS reception\n",
2625 (work32[2]&0x00000004) ? "+" : "-");
2626 len += sprintf(buf+len, " [%s] IPv4 checksum validation \n",
2627 (work32[2]&0x00000100) ? "+" : "-");
2628 len += sprintf(buf+len, " [%s] TCP checksum validation \n",
2629 (work32[2]&0x00000200) ? "+" : "-");
2630 len += sprintf(buf+len, " [%s] UDP checksum validation \n",
2631 (work32[2]&0x00000400) ? "+" : "-");
2632 len += sprintf(buf+len, " [%s] RSVP checksum validation \n",
2633 (work32[2]&0x00000800) ? "+" : "-");
2634 len += sprintf(buf+len, " [%s] ICMP checksum validation \n",
2635 (work32[2]&0x00001000) ? "+" : "-");
2637 spin_unlock(&i2o_proc_lock);
2641 static int i2o_report_opt_field(char *buf, char *field_name,
2642 int field_nbr, int supp_fields, u64 *value)
2644 if (supp_fields & (1 << field_nbr))
2645 return sprintf(buf, "%-24s : " FMT_U64_HEX "\n", field_name, U64_VAL(value));
2647 return sprintf(buf, "%-24s : Not supported\n", field_name);
2650 /* LAN group 0100h - LAN Historical statistics (scalar) */
2651 /* LAN group 0180h - Supported Optional Historical Statistics (scalar) */
2652 /* LAN group 0182h - Optional Non Media Specific Transmit Historical Statistics (scalar) */
2653 /* LAN group 0183h - Optional Non Media Specific Receive Historical Statistics (scalar) */
2655 int i2o_proc_read_lan_hist_stats(char *buf, char **start, off_t offset, int len,
2656 int *eof, void *data)
2658 struct i2o_device *d = (struct i2o_device*)data;
2671 u64 adapter_suspends;
2674 static u64 supp_groups[4]; // 0x0180
2679 u64 tx_directed_bytes;
2680 u64 tx_directed_packets;
2681 u64 tx_multicast_bytes;
2682 u64 tx_multicast_packets;
2683 u64 tx_broadcast_bytes;
2684 u64 tx_broadcast_packets;
2685 u64 tx_group_addr_packets;
2686 u64 tx_short_packets;
2687 } tx_stats; // 0x0182
2692 u64 rx_directed_bytes;
2693 u64 rx_directed_packets;
2694 u64 rx_multicast_bytes;
2695 u64 rx_multicast_packets;
2696 u64 rx_broadcast_bytes;
2697 u64 rx_broadcast_packets;
2698 u64 rx_group_addr_packets;
2699 u64 rx_short_packets;
2700 u64 rx_long_packets;
2701 u64 rx_runt_packets;
2702 } rx_stats; // 0x0183
2707 u64 ipv4_validate_success;
2708 u64 ipv4_validate_errors;
2710 u64 tcp_validate_success;
2711 u64 tcp_validate_errors;
2713 u64 udp_validate_success;
2714 u64 udp_validate_errors;
2716 u64 rsvp_validate_success;
2717 u64 rsvp_validate_errors;
2719 u64 icmp_validate_success;
2720 u64 icmp_validate_errors;
2721 } chksum_stats; // 0x0184
2723 spin_lock(&i2o_proc_lock);
2726 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2727 0x0100, -1, &stats, sizeof(stats));
2729 len += i2o_report_query_status(buf+len, token,"0x100 LAN Statistics");
2730 spin_unlock(&i2o_proc_lock);
2734 len += sprintf(buf+len, "Tx packets : " FMT_U64_HEX "\n",
2735 U64_VAL(&stats.tx_packets));
2736 len += sprintf(buf+len, "Tx bytes : " FMT_U64_HEX "\n",
2737 U64_VAL(&stats.tx_bytes));
2738 len += sprintf(buf+len, "Rx packets : " FMT_U64_HEX "\n",
2739 U64_VAL(&stats.rx_packets));
2740 len += sprintf(buf+len, "Rx bytes : " FMT_U64_HEX "\n",
2741 U64_VAL(&stats.rx_bytes));
2742 len += sprintf(buf+len, "Tx errors : " FMT_U64_HEX "\n",
2743 U64_VAL(&stats.tx_errors));
2744 len += sprintf(buf+len, "Rx errors : " FMT_U64_HEX "\n",
2745 U64_VAL(&stats.rx_errors));
2746 len += sprintf(buf+len, "Rx dropped : " FMT_U64_HEX "\n",
2747 U64_VAL(&stats.rx_dropped));
2748 len += sprintf(buf+len, "Adapter resets : " FMT_U64_HEX "\n",
2749 U64_VAL(&stats.adapter_resets));
2750 len += sprintf(buf+len, "Adapter suspends : " FMT_U64_HEX "\n",
2751 U64_VAL(&stats.adapter_suspends));
2753 /* Optional statistics follows */
2754 /* Get 0x0180 to see which optional groups/fields are supported */
2756 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2757 0x0180, -1, &supp_groups, sizeof(supp_groups));
2760 len += i2o_report_query_status(buf+len, token, "0x180 LAN Supported Optional Statistics");
2761 spin_unlock(&i2o_proc_lock);
2765 if (supp_groups[1]) /* 0x0182 */
2767 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2768 0x0182, -1, &tx_stats, sizeof(tx_stats));
2771 len += i2o_report_query_status(buf+len, token,"0x182 LAN Optional Tx Historical Statistics");
2772 spin_unlock(&i2o_proc_lock);
2776 len += sprintf(buf+len, "==== Optional TX statistics (group 0182h)\n");
2778 len += i2o_report_opt_field(buf+len, "Tx RetryCount",
2779 0, supp_groups[1], &tx_stats.tx_retries);
2780 len += i2o_report_opt_field(buf+len, "Tx DirectedBytes",
2781 1, supp_groups[1], &tx_stats.tx_directed_bytes);
2782 len += i2o_report_opt_field(buf+len, "Tx DirectedPackets",
2783 2, supp_groups[1], &tx_stats.tx_directed_packets);
2784 len += i2o_report_opt_field(buf+len, "Tx MulticastBytes",
2785 3, supp_groups[1], &tx_stats.tx_multicast_bytes);
2786 len += i2o_report_opt_field(buf+len, "Tx MulticastPackets",
2787 4, supp_groups[1], &tx_stats.tx_multicast_packets);
2788 len += i2o_report_opt_field(buf+len, "Tx BroadcastBytes",
2789 5, supp_groups[1], &tx_stats.tx_broadcast_bytes);
2790 len += i2o_report_opt_field(buf+len, "Tx BroadcastPackets",
2791 6, supp_groups[1], &tx_stats.tx_broadcast_packets);
2792 len += i2o_report_opt_field(buf+len, "Tx TotalGroupAddrPackets",
2793 7, supp_groups[1], &tx_stats.tx_group_addr_packets);
2794 len += i2o_report_opt_field(buf+len, "Tx TotalPacketsTooShort",
2795 8, supp_groups[1], &tx_stats.tx_short_packets);
2798 if (supp_groups[2]) /* 0x0183 */
2800 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2801 0x0183, -1, &rx_stats, sizeof(rx_stats));
2803 len += i2o_report_query_status(buf+len, token,"0x183 LAN Optional Rx Historical Stats");
2804 spin_unlock(&i2o_proc_lock);
2808 len += sprintf(buf+len, "==== Optional RX statistics (group 0183h)\n");
2810 len += i2o_report_opt_field(buf+len, "Rx CRCErrorCount",
2811 0, supp_groups[2], &rx_stats.rx_crc_errors);
2812 len += i2o_report_opt_field(buf+len, "Rx DirectedBytes",
2813 1, supp_groups[2], &rx_stats.rx_directed_bytes);
2814 len += i2o_report_opt_field(buf+len, "Rx DirectedPackets",
2815 2, supp_groups[2], &rx_stats.rx_directed_packets);
2816 len += i2o_report_opt_field(buf+len, "Rx MulticastBytes",
2817 3, supp_groups[2], &rx_stats.rx_multicast_bytes);
2818 len += i2o_report_opt_field(buf+len, "Rx MulticastPackets",
2819 4, supp_groups[2], &rx_stats.rx_multicast_packets);
2820 len += i2o_report_opt_field(buf+len, "Rx BroadcastBytes",
2821 5, supp_groups[2], &rx_stats.rx_broadcast_bytes);
2822 len += i2o_report_opt_field(buf+len, "Rx BroadcastPackets",
2823 6, supp_groups[2], &rx_stats.rx_broadcast_packets);
2824 len += i2o_report_opt_field(buf+len, "Rx TotalGroupAddrPackets",
2825 7, supp_groups[2], &rx_stats.rx_group_addr_packets);
2826 len += i2o_report_opt_field(buf+len, "Rx TotalPacketsTooShort",
2827 8, supp_groups[2], &rx_stats.rx_short_packets);
2828 len += i2o_report_opt_field(buf+len, "Rx TotalPacketsTooLong",
2829 9, supp_groups[2], &rx_stats.rx_long_packets);
2830 len += i2o_report_opt_field(buf+len, "Rx TotalPacketsRunt",
2831 10, supp_groups[2], &rx_stats.rx_runt_packets);
2834 if (supp_groups[3]) /* 0x0184 */
2836 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2837 0x0184, -1, &chksum_stats, sizeof(chksum_stats));
2840 len += i2o_report_query_status(buf+len, token,"0x184 LAN Optional Chksum Historical Stats");
2841 spin_unlock(&i2o_proc_lock);
2845 len += sprintf(buf+len, "==== Optional CHKSUM statistics (group 0x0184)\n");
2847 len += i2o_report_opt_field(buf+len, "IPv4 Generate",
2848 0, supp_groups[3], &chksum_stats.ipv4_generate);
2849 len += i2o_report_opt_field(buf+len, "IPv4 ValidateSuccess",
2850 1, supp_groups[3], &chksum_stats.ipv4_validate_success);
2851 len += i2o_report_opt_field(buf+len, "IPv4 ValidateError",
2852 2, supp_groups[3], &chksum_stats.ipv4_validate_errors);
2853 len += i2o_report_opt_field(buf+len, "TCP Generate",
2854 3, supp_groups[3], &chksum_stats.tcp_generate);
2855 len += i2o_report_opt_field(buf+len, "TCP ValidateSuccess",
2856 4, supp_groups[3], &chksum_stats.tcp_validate_success);
2857 len += i2o_report_opt_field(buf+len, "TCP ValidateError",
2858 5, supp_groups[3], &chksum_stats.tcp_validate_errors);
2859 len += i2o_report_opt_field(buf+len, "UDP Generate",
2860 6, supp_groups[3], &chksum_stats.udp_generate);
2861 len += i2o_report_opt_field(buf+len, "UDP ValidateSuccess",
2862 7, supp_groups[3], &chksum_stats.udp_validate_success);
2863 len += i2o_report_opt_field(buf+len, "UDP ValidateError",
2864 8, supp_groups[3], &chksum_stats.udp_validate_errors);
2865 len += i2o_report_opt_field(buf+len, "RSVP Generate",
2866 9, supp_groups[3], &chksum_stats.rsvp_generate);
2867 len += i2o_report_opt_field(buf+len, "RSVP ValidateSuccess",
2868 10, supp_groups[3], &chksum_stats.rsvp_validate_success);
2869 len += i2o_report_opt_field(buf+len, "RSVP ValidateError",
2870 11, supp_groups[3], &chksum_stats.rsvp_validate_errors);
2871 len += i2o_report_opt_field(buf+len, "ICMP Generate",
2872 12, supp_groups[3], &chksum_stats.icmp_generate);
2873 len += i2o_report_opt_field(buf+len, "ICMP ValidateSuccess",
2874 13, supp_groups[3], &chksum_stats.icmp_validate_success);
2875 len += i2o_report_opt_field(buf+len, "ICMP ValidateError",
2876 14, supp_groups[3], &chksum_stats.icmp_validate_errors);
2879 spin_unlock(&i2o_proc_lock);
2883 /* LAN group 0200h - Required Ethernet Statistics (scalar) */
2884 /* LAN group 0280h - Optional Ethernet Statistics Supported (scalar) */
2885 /* LAN group 0281h - Optional Ethernet Historical Statistics (scalar) */
2886 int i2o_proc_read_lan_eth_stats(char *buf, char **start, off_t offset,
2887 int len, int *eof, void *data)
2889 struct i2o_device *d = (struct i2o_device*)data;
2894 u64 rx_align_errors;
2895 u64 tx_one_collisions;
2896 u64 tx_multiple_collisions;
2898 u64 tx_late_collisions;
2899 u64 tx_max_collisions;
2900 u64 tx_carrier_lost;
2901 u64 tx_excessive_deferrals;
2904 static u64 supp_fields;
2909 u64 tx_heartbeat_failure;
2912 spin_lock(&i2o_proc_lock);
2915 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2916 0x0200, -1, &stats, sizeof(stats));
2919 len += i2o_report_query_status(buf+len, token,"0x0200 LAN Ethernet Statistics");
2920 spin_unlock(&i2o_proc_lock);
2924 len += sprintf(buf+len, "Rx alignment errors : " FMT_U64_HEX "\n",
2925 U64_VAL(&stats.rx_align_errors));
2926 len += sprintf(buf+len, "Tx one collisions : " FMT_U64_HEX "\n",
2927 U64_VAL(&stats.tx_one_collisions));
2928 len += sprintf(buf+len, "Tx multicollisions : " FMT_U64_HEX "\n",
2929 U64_VAL(&stats.tx_multiple_collisions));
2930 len += sprintf(buf+len, "Tx deferred : " FMT_U64_HEX "\n",
2931 U64_VAL(&stats.tx_deferred));
2932 len += sprintf(buf+len, "Tx late collisions : " FMT_U64_HEX "\n",
2933 U64_VAL(&stats.tx_late_collisions));
2934 len += sprintf(buf+len, "Tx max collisions : " FMT_U64_HEX "\n",
2935 U64_VAL(&stats.tx_max_collisions));
2936 len += sprintf(buf+len, "Tx carrier lost : " FMT_U64_HEX "\n",
2937 U64_VAL(&stats.tx_carrier_lost));
2938 len += sprintf(buf+len, "Tx excessive deferrals : " FMT_U64_HEX "\n",
2939 U64_VAL(&stats.tx_excessive_deferrals));
2941 /* Optional Ethernet statistics follows */
2942 /* Get 0x0280 to see which optional fields are supported */
2944 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2945 0x0280, -1, &supp_fields, sizeof(supp_fields));
2948 len += i2o_report_query_status(buf+len, token,"0x0280 LAN Supported Optional Ethernet Statistics");
2949 spin_unlock(&i2o_proc_lock);
2953 if (supp_fields) /* 0x0281 */
2955 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2956 0x0281, -1, &stats, sizeof(stats));
2959 len += i2o_report_query_status(buf+len, token,"0x0281 LAN Optional Ethernet Statistics");
2960 spin_unlock(&i2o_proc_lock);
2964 len += sprintf(buf+len, "==== Optional ETHERNET statistics (group 0x0281)\n");
2966 len += i2o_report_opt_field(buf+len, "Rx Overrun",
2967 0, supp_fields, &hist_stats.rx_overrun);
2968 len += i2o_report_opt_field(buf+len, "Tx Underrun",
2969 1, supp_fields, &hist_stats.tx_underrun);
2970 len += i2o_report_opt_field(buf+len, "Tx HeartbeatFailure",
2971 2, supp_fields, &hist_stats.tx_heartbeat_failure);
2974 spin_unlock(&i2o_proc_lock);
2978 /* LAN group 0300h - Required Token Ring Statistics (scalar) */
2979 /* LAN group 0380h, 0381h - Optional Statistics not yet defined (TODO) */
2980 int i2o_proc_read_lan_tr_stats(char *buf, char **start, off_t offset,
2981 int len, int *eof, void *data)
2983 struct i2o_device *d = (struct i2o_device*)data;
2984 static u64 work64[13];
2987 static char *ring_status[] =
2999 "Auto-Removal Error 1",
3007 spin_lock(&i2o_proc_lock);
3010 token = i2o_query_scalar(d->controller, d->lct_data.tid,
3011 0x0300, -1, &work64, sizeof(work64));
3014 len += i2o_report_query_status(buf+len, token,"0x0300 Token Ring Statistics");
3015 spin_unlock(&i2o_proc_lock);
3019 len += sprintf(buf, "LineErrors : " FMT_U64_HEX "\n",
3020 U64_VAL(&work64[0]));
3021 len += sprintf(buf+len, "LostFrames : " FMT_U64_HEX "\n",
3022 U64_VAL(&work64[1]));
3023 len += sprintf(buf+len, "ACError : " FMT_U64_HEX "\n",
3024 U64_VAL(&work64[2]));
3025 len += sprintf(buf+len, "TxAbortDelimiter : " FMT_U64_HEX "\n",
3026 U64_VAL(&work64[3]));
3027 len += sprintf(buf+len, "BursErrors : " FMT_U64_HEX "\n",
3028 U64_VAL(&work64[4]));
3029 len += sprintf(buf+len, "FrameCopiedErrors : " FMT_U64_HEX "\n",
3030 U64_VAL(&work64[5]));
3031 len += sprintf(buf+len, "FrequencyErrors : " FMT_U64_HEX "\n",
3032 U64_VAL(&work64[6]));
3033 len += sprintf(buf+len, "InternalErrors : " FMT_U64_HEX "\n",
3034 U64_VAL(&work64[7]));
3035 len += sprintf(buf+len, "LastRingStatus : %s\n", ring_status[work64[8]]);
3036 len += sprintf(buf+len, "TokenError : " FMT_U64_HEX "\n",
3037 U64_VAL(&work64[9]));
3038 len += sprintf(buf+len, "UpstreamNodeAddress : " FMT_U64_HEX "\n",
3039 U64_VAL(&work64[10]));
3040 len += sprintf(buf+len, "LastRingID : " FMT_U64_HEX "\n",
3041 U64_VAL(&work64[11]));
3042 len += sprintf(buf+len, "LastBeaconType : " FMT_U64_HEX "\n",
3043 U64_VAL(&work64[12]));
3045 spin_unlock(&i2o_proc_lock);
3049 /* LAN group 0400h - Required FDDI Statistics (scalar) */
3050 /* LAN group 0480h, 0481h - Optional Statistics, not yet defined (TODO) */
3051 int i2o_proc_read_lan_fddi_stats(char *buf, char **start, off_t offset,
3052 int len, int *eof, void *data)
3054 struct i2o_device *d = (struct i2o_device*)data;
3055 static u64 work64[11];
3058 static char *conf_state[] =
3075 static char *ring_state[] =
3087 static char *link_state[] =
3101 spin_lock(&i2o_proc_lock);
3104 token = i2o_query_scalar(d->controller, d->lct_data.tid,
3105 0x0400, -1, &work64, sizeof(work64));
3108 len += i2o_report_query_status(buf+len, token,"0x0400 FDDI Required Statistics");
3109 spin_unlock(&i2o_proc_lock);
3113 len += sprintf(buf+len, "ConfigurationState : %s\n", conf_state[work64[0]]);
3114 len += sprintf(buf+len, "UpstreamNode : " FMT_U64_HEX "\n",
3115 U64_VAL(&work64[1]));
3116 len += sprintf(buf+len, "DownStreamNode : " FMT_U64_HEX "\n",
3117 U64_VAL(&work64[2]));
3118 len += sprintf(buf+len, "FrameErrors : " FMT_U64_HEX "\n",
3119 U64_VAL(&work64[3]));
3120 len += sprintf(buf+len, "FramesLost : " FMT_U64_HEX "\n",
3121 U64_VAL(&work64[4]));
3122 len += sprintf(buf+len, "RingMgmtState : %s\n", ring_state[work64[5]]);
3123 len += sprintf(buf+len, "LCTFailures : " FMT_U64_HEX "\n",
3124 U64_VAL(&work64[6]));
3125 len += sprintf(buf+len, "LEMRejects : " FMT_U64_HEX "\n",
3126 U64_VAL(&work64[7]));
3127 len += sprintf(buf+len, "LEMCount : " FMT_U64_HEX "\n",
3128 U64_VAL(&work64[8]));
3129 len += sprintf(buf+len, "LConnectionState : %s\n",
3130 link_state[work64[9]]);
3132 spin_unlock(&i2o_proc_lock);
3136 static int i2o_proc_create_entries(void *data, i2o_proc_entry *pentry,
3137 struct proc_dir_entry *parent)
3139 struct proc_dir_entry *ent;
3141 while(pentry->name != NULL)
3143 ent = create_proc_entry(pentry->name, pentry->mode, parent);
3147 ent->read_proc = pentry->read_proc;
3148 ent->write_proc = pentry->write_proc;
3157 static void i2o_proc_remove_entries(i2o_proc_entry *pentry,
3158 struct proc_dir_entry *parent)
3160 while(pentry->name != NULL)
3162 remove_proc_entry(pentry->name, parent);
3167 static int i2o_proc_add_controller(struct i2o_controller *pctrl,
3168 struct proc_dir_entry *root )
3170 struct proc_dir_entry *dir, *dir1;
3171 struct i2o_device *dev;
3174 sprintf(buff, "iop%d", pctrl->unit);
3176 dir = proc_mkdir(buff, root);
3180 pctrl->proc_entry = dir;
3182 i2o_proc_create_entries(pctrl, generic_iop_entries, dir);
3184 for(dev = pctrl->devices; dev; dev = dev->next)
3186 sprintf(buff, "%0#5x", dev->lct_data.tid);
3188 dir1 = proc_mkdir(buff, dir);
3189 dev->proc_entry = dir1;
3192 printk(KERN_INFO "i2o_proc: Could not allocate proc dir\n");
3194 i2o_proc_add_device(dev, dir1);
3200 void i2o_proc_new_dev(struct i2o_controller *c, struct i2o_device *d)
3205 printk(KERN_INFO "Adding new device to /proc/i2o/iop%d\n", c->unit);
3207 sprintf(buff, "%0#5x", d->lct_data.tid);
3209 d->proc_entry = proc_mkdir(buff, c->proc_entry);
3213 printk(KERN_WARNING "i2o: Could not allocate procdir!\n");
3217 i2o_proc_add_device(d, d->proc_entry);
3220 void i2o_proc_add_device(struct i2o_device *dev, struct proc_dir_entry *dir)
3222 i2o_proc_create_entries(dev, generic_dev_entries, dir);
3224 /* Inform core that we want updates about this device's status */
3225 i2o_device_notify_on(dev, &i2o_proc_handler);
3226 switch(dev->lct_data.class_id)
3228 case I2O_CLASS_SCSI_PERIPHERAL:
3229 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
3230 i2o_proc_create_entries(dev, rbs_dev_entries, dir);
3233 i2o_proc_create_entries(dev, lan_entries, dir);
3234 switch(dev->lct_data.sub_class)
3236 case I2O_LAN_ETHERNET:
3237 i2o_proc_create_entries(dev, lan_eth_entries, dir);
3240 i2o_proc_create_entries(dev, lan_fddi_entries, dir);
3243 i2o_proc_create_entries(dev, lan_tr_entries, dir);
3254 static void i2o_proc_remove_controller(struct i2o_controller *pctrl,
3255 struct proc_dir_entry *parent)
3258 struct i2o_device *dev;
3260 /* Remove unused device entries */
3261 for(dev=pctrl->devices; dev; dev=dev->next)
3262 i2o_proc_remove_device(dev);
3264 if(!atomic_read(&pctrl->proc_entry->count))
3266 sprintf(buff, "iop%d", pctrl->unit);
3268 i2o_proc_remove_entries(generic_iop_entries, pctrl->proc_entry);
3270 remove_proc_entry(buff, parent);
3271 pctrl->proc_entry = NULL;
3275 void i2o_proc_remove_device(struct i2o_device *dev)
3277 struct proc_dir_entry *de=dev->proc_entry;
3280 sprintf(dev_id, "%0#5x", dev->lct_data.tid);
3282 i2o_device_notify_off(dev, &i2o_proc_handler);
3283 /* Would it be safe to remove _files_ even if they are in use? */
3284 if((de) && (!atomic_read(&de->count)))
3286 i2o_proc_remove_entries(generic_dev_entries, de);
3287 switch(dev->lct_data.class_id)
3289 case I2O_CLASS_SCSI_PERIPHERAL:
3290 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
3291 i2o_proc_remove_entries(rbs_dev_entries, de);
3295 i2o_proc_remove_entries(lan_entries, de);
3296 switch(dev->lct_data.sub_class)
3298 case I2O_LAN_ETHERNET:
3299 i2o_proc_remove_entries(lan_eth_entries, de);
3302 i2o_proc_remove_entries(lan_fddi_entries, de);
3305 i2o_proc_remove_entries(lan_tr_entries, de);
3309 remove_proc_entry(dev_id, dev->controller->proc_entry);
3314 void i2o_proc_dev_del(struct i2o_controller *c, struct i2o_device *d)
3317 printk(KERN_INFO "Deleting device %d from iop%d\n",
3318 d->lct_data.tid, c->unit);
3321 i2o_proc_remove_device(d);
3324 static int create_i2o_procfs(void)
3326 struct i2o_controller *pctrl = NULL;
3329 i2o_proc_dir_root = proc_mkdir("i2o", 0);
3330 if(!i2o_proc_dir_root)
3333 for(i = 0; i < MAX_I2O_CONTROLLERS; i++)
3335 pctrl = i2o_find_controller(i);
3338 i2o_proc_add_controller(pctrl, i2o_proc_dir_root);
3339 i2o_unlock_controller(pctrl);
3346 static int __exit destroy_i2o_procfs(void)
3348 struct i2o_controller *pctrl = NULL;
3351 for(i = 0; i < MAX_I2O_CONTROLLERS; i++)
3353 pctrl = i2o_find_controller(i);
3356 i2o_proc_remove_controller(pctrl, i2o_proc_dir_root);
3357 i2o_unlock_controller(pctrl);
3361 if(!atomic_read(&i2o_proc_dir_root->count))
3362 remove_proc_entry("i2o", 0);
3369 int __init i2o_proc_init(void)
3371 if (i2o_install_handler(&i2o_proc_handler) < 0)
3373 printk(KERN_ERR "i2o_proc: Unable to install PROC handler.\n");
3377 if(create_i2o_procfs())
3383 MODULE_AUTHOR("Deepak Saxena");
3384 MODULE_DESCRIPTION("I2O procfs Handler");
3385 MODULE_LICENSE("GPL");
3387 static void __exit i2o_proc_exit(void)
3389 destroy_i2o_procfs();
3390 i2o_remove_handler(&i2o_proc_handler);
3394 module_init(i2o_proc_init);
3396 module_exit(i2o_proc_exit);