Import 2.3.18pre1
[davej-history.git] / drivers / i2o / i2o_proc.c
blob23232e8ef280727b1b7938e9b0939f774e7f8fd6
1 /*
2 * procfs handler for Linux I2O subsystem
4 * Copyright (c) 1999 Intel Corporation
5 *
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
26 * set tabstop=3
30 * TODO List
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
37 // FIXME!
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/i2o.h>
44 #include <linux/proc_fs.h>
45 #include <linux/init.h>
46 #include <linux/module.h>
47 #include <linux/errno.h>
48 #include <linux/spinlock.h>
50 #include <asm/io.h>
51 #include <asm/uaccess.h>
52 #include <asm/byteorder.h>
55 #include "i2o_proc.h"
57 #include "i2o_lan.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 } i2o_proc_entry;
70 static int proc_context = 0;
73 static int i2o_proc_read_lct(char *, char **, off_t, int, int *, void *);
74 static int i2o_proc_read_hrt(char *, char **, off_t, int, int *, void *);
75 static int i2o_proc_read_stat(char *, char **, off_t, int, int *, void *);
76 static int i2o_proc_read_hw(char *, char **, off_t, int, int *, void *);
77 static int i2o_proc_read_dst(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_ds(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_priv_msgs(char *, char **, off_t, int, int *, void *);
82 static int i2o_proc_read_dev(char *, char **, off_t, int, int *, void *);
83 static int i2o_proc_read_dev_name(char *, char **, off_t, int, int *, void *);
84 static int i2o_proc_read_ddm(char *, char **, off_t, int, int *, void *);
85 static int i2o_proc_read_uinfo(char *, char **, off_t, int, int *, void *);
86 static int i2o_proc_read_sgl_limits(char *, char **, off_t, int, int *, void *);
87 static int print_serial_number(char *, int, u8 *, int);
88 static int i2o_proc_create_entries(void *,
89 i2o_proc_entry *, struct proc_dir_entry *);
90 static void i2o_proc_remove_entries(i2o_proc_entry *, struct proc_dir_entry *);
91 static int i2o_proc_add_controller(struct i2o_controller *,
92 struct proc_dir_entry * );
93 static void i2o_proc_remove_controller(struct i2o_controller *,
94 struct proc_dir_entry * );
95 static int create_i2o_procfs(void);
96 static int destroy_i2o_procfs(void);
97 static void i2o_proc_reply(struct i2o_handler *, struct i2o_controller *,
98 struct i2o_message *);
100 static int i2o_proc_read_lan_dev_info(char *, char **, off_t, int, int *,
101 void *);
102 static int i2o_proc_read_lan_mac_addr(char *, char **, off_t, int, int *,
103 void *);
104 static int i2o_proc_read_lan_mcast_addr(char *, char **, off_t, int, int *,
105 void *);
106 static int i2o_proc_read_lan_batch_control(char *, char **, off_t, int, int *,
107 void *);
108 static int i2o_proc_read_lan_operation(char *, char **, off_t, int, int *,
109 void *);
110 static int i2o_proc_read_lan_media_operation(char *, char **, off_t, int,
111 int *, void *);
112 static int i2o_proc_read_lan_alt_addr(char *, char **, off_t, int, int *,
113 void *);
114 static int i2o_proc_read_lan_tx_info(char *, char **, off_t, int, int *,
115 void *);
116 static int i2o_proc_read_lan_rx_info(char *, char **, off_t, int, int *,
117 void *);
118 static int i2o_proc_read_lan_hist_stats(char *, char **, off_t, int, int *,
119 void *);
120 static int i2o_proc_read_lan_supp_opt_stats(char *, char **, off_t, int, int *,
121 void *);
122 static int i2o_proc_read_lan_opt_tx_hist_stats(char *, char **, off_t, int,
123 int *, void *);
124 static int i2o_proc_read_lan_opt_rx_hist_stats(char *, char **, off_t, int,
125 int *, void *);
126 static int i2o_proc_read_lan_eth_stats(char *, char **, off_t, int,
127 int *, void *);
128 static int i2o_proc_read_lan_supp_eth_stats(char *, char **, off_t, int, int *,
129 void *);
130 static int i2o_proc_read_lan_opt_eth_stats(char *, char **, off_t, int, int *,
131 void *);
132 static int i2o_proc_read_lan_tr_stats(char *, char **, off_t, int, int *,
133 void *);
134 static int i2o_proc_read_lan_fddi_stats(char *, char **, off_t, int, int *,
135 void *);
137 static struct proc_dir_entry *i2o_proc_dir_root;
140 * Message handler
142 static struct i2o_handler i2o_proc_handler =
144 (void *)i2o_proc_reply,
145 "I2O procfs Layer",
147 0xffffffff // All classes
151 * IOP specific entries...write field just in case someone
152 * ever wants one.
154 static i2o_proc_entry generic_iop_entries[] =
156 {"hrt", S_IFREG|S_IRUGO, i2o_proc_read_hrt, NULL},
157 {"lct", S_IFREG|S_IRUGO, i2o_proc_read_lct, NULL},
158 {"stat", S_IFREG|S_IRUGO, i2o_proc_read_stat, NULL},
159 {"hw", S_IFREG|S_IRUGO, i2o_proc_read_hw, NULL},
160 {"dst", S_IFREG|S_IRUGO, i2o_proc_read_dst, NULL},
161 {"ddm_table", S_IFREG|S_IRUGO, i2o_proc_read_ddm_table, NULL},
162 {"ds", S_IFREG|S_IRUGO, i2o_proc_read_ds, NULL},
163 {NULL, 0, NULL, NULL}
167 * Device specific entries
169 static i2o_proc_entry generic_dev_entries[] =
171 {"groups", S_IFREG|S_IRUGO, i2o_proc_read_groups, NULL},
172 {"priv_msgs", S_IFREG|S_IRUGO, i2o_proc_read_priv_msgs, NULL},
173 {"dev_identity", S_IFREG|S_IRUGO, i2o_proc_read_dev, NULL},
174 {"ddm_identity", S_IFREG|S_IRUGO, i2o_proc_read_ddm, NULL},
175 {"sgl_limits", S_IFREG|S_IRUGO, i2o_proc_read_sgl_limits, NULL},
176 {"user_info", S_IFREG|S_IRUGO, i2o_proc_read_uinfo, NULL},
177 {NULL, 0, NULL, NULL}
181 * Storage unit specific entries (SCSI Periph, BS) with device names
183 static i2o_proc_entry rbs_dev_entries[] =
185 {"dev_name", S_IFREG|S_IRUGO, i2o_proc_read_dev_name, NULL},
186 {NULL, 0, NULL, NULL}
189 #define SCSI_TABLE_SIZE 13
190 static char *scsi_devices[] =
192 "Direct-Access Read/Write",
193 "Sequential-Access Storage",
194 "Printer",
195 "Processor",
196 "WORM Device",
197 "CD-ROM Device",
198 "Scanner Device",
199 "Optical Memory Device",
200 "Medium Changer Device",
201 "Communications Device",
202 "Graphics Art Pre-Press Device",
203 "Graphics Art Pre-Press Device",
204 "Array Controller Device"
207 /* private */
210 * Generic LAN specific entries
212 * Should groups with r/w entries have their own subdirectory?
215 static i2o_proc_entry lan_entries[] =
217 /* LAN param groups 0000h-0008h */
218 {"lan_dev_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_dev_info, NULL},
219 {"lan_mac_addr", S_IFREG|S_IRUGO, i2o_proc_read_lan_mac_addr, NULL},
220 {"lan_mcast_addr", S_IFREG|S_IRUGO|S_IWUSR,
221 i2o_proc_read_lan_mcast_addr, NULL},
222 {"lan_batch_ctrl", S_IFREG|S_IRUGO|S_IWUSR,
223 i2o_proc_read_lan_batch_control, NULL},
224 {"lan_operation", S_IFREG|S_IRUGO, i2o_proc_read_lan_operation, NULL},
225 {"lan_media_operation", S_IFREG|S_IRUGO,
226 i2o_proc_read_lan_media_operation, NULL},
227 {"lan_alt_addr", S_IFREG|S_IRUGO, i2o_proc_read_lan_alt_addr, NULL},
228 {"lan_tx_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_tx_info, NULL},
229 {"lan_rx_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_rx_info, NULL},
230 /* LAN param groups 0100h, 0180h, 0182h, 0183h */
231 {"lan_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_hist_stats, NULL},
232 {"lan_supp_opt_stats", S_IFREG|S_IRUGO,
233 i2o_proc_read_lan_supp_opt_stats, NULL},
234 {"lan_opt_tx_stats", S_IFREG|S_IRUGO,
235 i2o_proc_read_lan_opt_tx_hist_stats, NULL},
236 {"lan_opt_rx_stats", S_IFREG|S_IRUGO,
237 i2o_proc_read_lan_opt_rx_hist_stats, NULL},
238 /* TODO: LAN param group 0184h */
239 {NULL, 0, NULL, NULL}
243 * Ethernet specific LAN entries
246 static i2o_proc_entry lan_eth_entries[] =
248 /* LAN param groups 0200h, 0280h, 0281h */
249 {"lan_eth_stat", S_IFREG|S_IRUGO, i2o_proc_read_lan_eth_stats, NULL},
250 {"lan_supp_eth_stats", S_IFREG|S_IRUGO,
251 i2o_proc_read_lan_supp_eth_stats, NULL},
252 {"lan_opt_eth_stats", S_IFREG|S_IRUGO,
253 i2o_proc_read_lan_opt_eth_stats, NULL},
254 {NULL, 0, NULL, NULL}
258 * Token Ring specific LAN entries
261 static i2o_proc_entry lan_tr_entries[] =
263 /* LAN param group 0300h */
264 {"lan_tr_stats", S_IFREG|S_IRUGO,
265 i2o_proc_read_lan_tr_stats, NULL},
266 /* TODO: LAN param group 0380h, 0381h */
267 {NULL, 0, NULL, NULL}
271 * FDDI specific LAN entries
274 static i2o_proc_entry lan_fddi_entries[] =
276 /* LAN param group 0400h */
277 {"lan_fddi_stats", S_IFREG|S_IRUGO,
278 i2o_proc_read_lan_fddi_stats, NULL},
279 /* TODO: LAN param group 0480h, 0481h */
280 {NULL, 0, NULL, NULL}
284 static u32 i2o_proc_token = 0;
286 static char *chtostr(u8 *chars, int n)
288 char tmp[256];
289 tmp[0] = 0;
290 return strncat(tmp, (char *)chars, n);
293 static char* bus_strings[] =
295 "Local Bus",
296 "ISA",
297 "EISA",
298 "MCA",
299 "PCI",
300 "PCMCIA",
301 "NUBUS",
302 "CARDBUS"
305 static spinlock_t i2o_proc_lock = SPIN_LOCK_UNLOCKED;
307 void i2o_proc_reply(struct i2o_handler *phdlr, struct i2o_controller *pctrl,
308 struct i2o_message *pmsg)
310 i2o_proc_token = I2O_POST_WAIT_OK;
313 int i2o_proc_read_hrt(char *buf, char **start, off_t offset, int len,
314 int *eof, void *data)
316 struct i2o_controller *c = (struct i2o_controller *)data;
317 pi2o_hrt hrt;
318 u32 msg[6];
319 u32 *workspace;
320 u32 bus;
321 int count;
322 int i;
323 int token;
325 spin_lock(&i2o_proc_lock);
327 len = 0;
329 workspace = kmalloc(2048, GFP_KERNEL);
330 hrt = (pi2o_hrt)workspace;
331 if(workspace==NULL)
333 len += sprintf(buf, "No free memory for HRT buffer\n");
334 spin_unlock(&i2o_proc_lock);
335 return len;
338 memset(workspace, 0, 2048);
340 msg[0]= SIX_WORD_MSG_SIZE| SGL_OFFSET_4;
341 msg[1]= I2O_CMD_HRT_GET<<24 | HOST_TID<<12 | ADAPTER_TID;
342 msg[2]= (u32)proc_context;
343 msg[3]= 0;
344 msg[4]= (0xD0000000 | 2048);
345 msg[5]= virt_to_phys(workspace);
347 token = i2o_post_wait(c, ADAPTER_TID, msg, 6*4, &i2o_proc_token,2);
348 if(token == I2O_POST_WAIT_TIMEOUT)
350 kfree(workspace);
351 len += sprintf(buf, "Timeout waiting for HRT\n");
352 spin_unlock(&i2o_proc_lock);
353 return len;
356 if(hrt->hrt_version)
358 kfree(workspace);
359 len += sprintf(buf+len,
360 "HRT table for controller is too new a version.\n");
361 spin_unlock(&i2o_proc_lock);
362 return len;
365 count = hrt->num_entries;
367 if((count * hrt->entry_len + 8) > 2048) {
368 printk(KERN_WARNING "i2o_proc: HRT does not fit into buffer\n");
369 kfree(workspace);
370 len += sprintf(buf+len,
371 "HRT table too big to fit in buffer.\n");
372 spin_unlock(&i2o_proc_lock);
373 return len;
376 len += sprintf(buf+len, "HRT has %d entries of %d bytes each.\n",
377 count, hrt->entry_len);
379 for(i = 0; i < count; i++)
381 len += sprintf(buf+len, "Entry %d:\n", i);
382 len += sprintf(buf+len, " Adapter ID: %0#10x\n",
383 hrt->hrt_entry[i].adapter_id);
384 len += sprintf(buf+len, " Controlled by: %0#6x\n",
385 hrt->hrt_entry[i].parent_tid);
386 len += sprintf(buf+len, " Bus#%d\n",
387 hrt->hrt_entry[i].bus_num);
389 if(hrt->hrt_entry[i].bus_type != 0x80)
391 bus = hrt->hrt_entry[i].bus_type;
392 len += sprintf(buf+len, " %s Information\n", bus_strings[bus]);
394 switch(bus)
396 case I2O_BUS_LOCAL:
397 len += sprintf(buf+len, " IOBase: %0#6x,",
398 hrt->hrt_entry[i].bus.local_bus.LbBaseIOPort);
399 len += sprintf(buf+len, " MemoryBase: %0#10x\n",
400 hrt->hrt_entry[i].bus.local_bus.LbBaseMemoryAddress);
401 break;
403 case I2O_BUS_ISA:
404 len += sprintf(buf+len, " IOBase: %0#6x,",
405 hrt->hrt_entry[i].bus.isa_bus.IsaBaseIOPort);
406 len += sprintf(buf+len, " MemoryBase: %0#10x,",
407 hrt->hrt_entry[i].bus.isa_bus.IsaBaseMemoryAddress);
408 len += sprintf(buf+len, " CSN: %0#4x,",
409 hrt->hrt_entry[i].bus.isa_bus.CSN);
410 break;
412 case I2O_BUS_EISA:
413 len += sprintf(buf+len, " IOBase: %0#6x,",
414 hrt->hrt_entry[i].bus.eisa_bus.EisaBaseIOPort);
415 len += sprintf(buf+len, " MemoryBase: %0#10x,",
416 hrt->hrt_entry[i].bus.eisa_bus.EisaBaseMemoryAddress);
417 len += sprintf(buf+len, " Slot: %0#4x,",
418 hrt->hrt_entry[i].bus.eisa_bus.EisaSlotNumber);
419 break;
421 case I2O_BUS_MCA:
422 len += sprintf(buf+len, " IOBase: %0#6x,",
423 hrt->hrt_entry[i].bus.mca_bus.McaBaseIOPort);
424 len += sprintf(buf+len, " MemoryBase: %0#10x,",
425 hrt->hrt_entry[i].bus.mca_bus.McaBaseMemoryAddress);
426 len += sprintf(buf+len, " Slot: %0#4x,",
427 hrt->hrt_entry[i].bus.mca_bus.McaSlotNumber);
428 break;
430 case I2O_BUS_PCI:
431 len += sprintf(buf+len, " Bus: %0#4x",
432 hrt->hrt_entry[i].bus.pci_bus.PciBusNumber);
433 len += sprintf(buf+len, " Dev: %0#4x",
434 hrt->hrt_entry[i].bus.pci_bus.PciDeviceNumber);
435 len += sprintf(buf+len, " Func: %0#4x",
436 hrt->hrt_entry[i].bus.pci_bus.PciFunctionNumber);
437 len += sprintf(buf+len, " Vendor: %0#6x",
438 hrt->hrt_entry[i].bus.pci_bus.PciVendorID);
439 len += sprintf(buf+len, " Device: %0#6x\n",
440 hrt->hrt_entry[i].bus.pci_bus.PciDeviceID);
441 break;
443 default:
444 len += sprintf(buf+len, " Unsupported Bus Type\n");
447 else
448 len += sprintf(buf+len, " Unknown Bus Type\n");
451 kfree(workspace);
453 spin_unlock(&i2o_proc_lock);
455 return len;
458 int i2o_proc_read_lct(char *buf, char **start, off_t offset, int len,
459 int *eof, void *data)
461 struct i2o_controller *c = (struct i2o_controller*)data;
462 u32 msg[8];
463 u32 *workspace;
464 pi2o_lct lct; /* = (pi2o_lct)c->lct; */
465 int entries;
466 int token;
467 int i;
469 #define BUS_TABLE_SIZE 3
470 static char *bus_ports[] =
472 "Generic Bus",
473 "SCSI Bus",
474 "Fibre Channel Bus"
477 spin_lock(&i2o_proc_lock);
479 len = 0;
481 workspace = kmalloc(8192, GFP_KERNEL);
482 lct = (pi2o_lct)workspace;
483 if(workspace==NULL)
485 len += sprintf(buf, "No free memory for LCT buffer\n");
486 spin_unlock(&i2o_proc_lock);
487 return len;
490 memset(workspace, 0, 8192);
492 msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_6;
493 msg[1] = I2O_CMD_LCT_NOTIFY<<24 | HOST_TID<<12 | ADAPTER_TID;
494 msg[2] = (u32)proc_context;
495 msg[3] = 0;
496 msg[4] = 0xFFFFFFFF; /* All devices */
497 msg[5] = 0x00000000; /* Report now */
498 msg[6] = 0xD0000000|8192;
499 msg[7] = virt_to_bus(workspace);
501 token = i2o_post_wait(c, ADAPTER_TID, msg, 8*4, &i2o_proc_token,2);
502 if(token == I2O_POST_WAIT_TIMEOUT)
504 kfree(workspace);
505 len += sprintf(buf, "Timeout waiting for LCT\n");
506 spin_unlock(&i2o_proc_lock);
507 return len;
510 entries = (lct->table_size - 3)/9;
512 len += sprintf(buf, "LCT contains %d %s\n", entries,
513 entries == 1 ? "entry" : "entries");
514 if(lct->boot_tid)
515 len += sprintf(buf+len, "Boot Device @ ID %d\n", lct->boot_tid);
517 for(i = 0; i < entries; i++)
519 len += sprintf(buf+len, "Entry %d\n", i);
521 len += sprintf(buf+len, " %s", i2o_get_class_name(lct->lct_entry[i].class_id));
524 * Classes which we'll print subclass info for
526 switch(lct->lct_entry[i].class_id & 0xFFF)
528 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
529 switch(lct->lct_entry[i].sub_class)
531 case 0x00:
532 len += sprintf(buf+len, ": Direct-Access Read/Write");
533 break;
535 case 0x04:
536 len += sprintf(buf+len, ": WORM Drive");
537 break;
539 case 0x05:
540 len += sprintf(buf+len, ": CD-ROM Drive");
541 break;
543 case 0x07:
544 len += sprintf(buf+len, ": Optical Memory Device");
545 break;
547 default:
548 len += sprintf(buf+len, ": Unknown (0x%02x)",
549 lct->lct_entry[i].sub_class);
550 break;
552 break;
554 case I2O_CLASS_LAN:
555 switch(lct->lct_entry[i].sub_class & 0xFF)
557 case 0x30:
558 len += sprintf(buf+len, ": Ethernet");
559 break;
561 case 0x40:
562 len += sprintf(buf+len, ": 100base VG");
563 break;
565 case 0x50:
566 len += sprintf(buf+len, ": IEEE 802.5/Token-Ring");
567 break;
569 case 0x60:
570 len += sprintf(buf+len, ": ANSI X3T9.5 FDDI");
571 break;
573 case 0x70:
574 len += sprintf(buf+len, ": Fibre Channel");
575 break;
577 default:
578 len += sprintf(buf+len, ": Unknown Sub-Class (0x%02x)",
579 lct->lct_entry[i].sub_class & 0xFF);
580 break;
582 break;
584 case I2O_CLASS_SCSI_PERIPHERAL:
585 if(lct->lct_entry[i].sub_class < SCSI_TABLE_SIZE)
586 len += sprintf(buf+len, ": %s",
587 scsi_devices[lct->lct_entry[i].sub_class]);
588 else
589 len += sprintf(buf+len, ": Unknown Device Type");
590 break;
592 case I2O_CLASS_BUS_ADAPTER_PORT:
593 if(lct->lct_entry[i].sub_class < BUS_TABLE_SIZE)
594 len += sprintf(buf+len, ": %s",
595 bus_ports[lct->lct_entry[i].sub_class]);
596 else
597 len += sprintf(buf+len, ": Unknown Bus Type");
598 break;
600 len += sprintf(buf+len, "\n");
602 len += sprintf(buf+len, " Local TID: 0x%03x\n", lct->lct_entry[i].tid);
603 len += sprintf(buf+len, " User TID: 0x%03x\n", lct->lct_entry[i].user_tid);
604 len += sprintf(buf+len, " Parent TID: 0x%03x\n",
605 lct->lct_entry[i].parent_tid);
606 len += sprintf(buf+len, " Identity Tag: 0x%x%x%x%x%x%x%x%x\n",
607 lct->lct_entry[i].identity_tag[0],
608 lct->lct_entry[i].identity_tag[1],
609 lct->lct_entry[i].identity_tag[2],
610 lct->lct_entry[i].identity_tag[3],
611 lct->lct_entry[i].identity_tag[4],
612 lct->lct_entry[i].identity_tag[5],
613 lct->lct_entry[i].identity_tag[6],
614 lct->lct_entry[i].identity_tag[7]);
615 len += sprintf(buf+len, " Change Indicator: %0#10x\n",
616 lct->lct_entry[i].change_ind);
617 len += sprintf(buf+len, " Device Flags: %0#10x\n",
618 lct->lct_entry[i].device_flags);
621 kfree(workspace);
622 spin_unlock(&i2o_proc_lock);
624 return len;
627 int i2o_proc_read_stat(char *buf, char **start, off_t offset, int len,
628 int *eof, void *data)
630 struct i2o_controller *c = (struct i2o_controller*)data;
631 u32 *msg;
632 u32 m;
633 u8 *workspace;
634 u16 *work16;
635 u32 *work32;
636 long time;
637 char prodstr[25];
638 int version;
640 spin_lock(&i2o_proc_lock);
642 len = 0;
644 workspace = (u8*)kmalloc(88, GFP_KERNEL);
645 if(!workspace)
647 len += sprintf(buf, "No memory for status transfer\n");
648 spin_unlock(&i2o_proc_lock);
649 return len;
652 m = I2O_POST_READ32(c);
653 if(m == 0xFFFFFFFF)
655 len += sprintf(buf, "Could not get inbound message frame from IOP!\n");
656 kfree(workspace);
657 spin_unlock(&i2o_proc_lock);
658 return len;
661 msg = (u32 *)(m+c->mem_offset);
663 memset(workspace, 0, 88);
664 work32 = (u32*)workspace;
665 work16 = (u16*)workspace;
667 msg[0] = NINE_WORD_MSG_SIZE|SGL_OFFSET_0;
668 msg[1] = I2O_CMD_STATUS_GET<<24|HOST_TID<<12|ADAPTER_TID;
669 msg[2] = msg[3] = msg[4] = msg[5] = 0;
670 msg[6] = virt_to_phys(workspace);
671 msg[7] = 0; /* FIXME: 64-bit */
672 msg[8] = 88;
675 * hmm...i2o_post_message should just take ptr to message, and
676 * determine offset on it's own...less work for OSM developers
678 i2o_post_message(c, m);
680 time = jiffies;
682 while(workspace[87] != 0xFF)
684 if(jiffies-time >= 2*HZ)
686 len += sprintf(buf, "Timeout waiting for status reply\n");
687 kfree(workspace);
688 spin_unlock(&i2o_proc_lock);
689 return len;
691 schedule();
692 barrier();
695 len += sprintf(buf+len, "Organization ID: %0#6x\n", work16[0]);
697 version = workspace[9]&0xF0>>4;
698 if(version == 0x02) {
699 len += sprintf(buf+len, "Lowest I2O version supported: ");
700 switch(workspace[2]) {
701 case 0x00:
702 len += sprintf(buf+len, "1.0\n");
703 break;
704 case 0x01:
705 len += sprintf(buf+len, "1.5\n");
706 break;
707 case 0x02:
708 len += sprintf(buf+len, "2.0\n");
709 break;
712 len += sprintf(buf+len, "Highest I2O version supported: ");
713 switch(workspace[3]) {
714 case 0x00:
715 len += sprintf(buf+len, "1.0\n");
716 break;
717 case 0x01:
718 len += sprintf(buf+len, "1.5\n");
719 break;
720 case 0x02:
721 len += sprintf(buf+len, "2.0\n");
722 break;
726 len += sprintf(buf+len, "IOP ID: %0#5x\n", work16[2]&0xFFF);
727 len += sprintf(buf+len, "Host Unit ID: %0#6x\n", work16[3]);
728 len += sprintf(buf+len, "Segment Number: %0#5x\n", work16[4]&0XFFF);
730 len += sprintf(buf+len, "I2O version: ");
731 switch(version)
733 case 0x00:
734 len += sprintf(buf+len, "1.0\n");
735 break;
736 case 0x01:
737 len += sprintf(buf+len, "1.5\n");
738 break;
739 case 0x02:
740 len += sprintf(buf+len, "2.0\n");
741 break;
742 default:
743 len += sprintf(buf+len, "Unknown version\n");
746 len += sprintf(buf+len, "IOP State: ");
747 switch(workspace[10])
749 case 0x01:
750 len += sprintf(buf+len, "Init\n");
751 break;
753 case 0x02:
754 len += sprintf(buf+len, "Reset\n");
755 break;
757 case 0x04:
758 len += sprintf(buf+len, "Hold\n");
759 break;
761 case 0x05:
762 len += sprintf(buf+len, "Hold\n");
763 break;
765 case 0x08:
766 len += sprintf(buf+len, "Operational\n");
767 break;
769 case 0x10:
770 len += sprintf(buf+len, "FAILED\n");
771 break;
773 case 0x11:
774 len += sprintf(buf+len, "FAULTED\n");
775 break;
777 default:
778 len += sprintf(buf+len, "Unknown\n");
779 break;
782 /* 0x00 is the only type supported w/spec 1.5 */
783 /* Added 2.0 types */
784 len += sprintf(buf+len, "Messenger Type: ");
785 switch (workspace[11])
787 case 0x00:
788 len += sprintf(buf+len, "Memory mapped\n");
789 break;
790 case 0x01:
791 len += sprintf(buf+len, "Memory mapped only\n");
792 break;
793 case 0x02:
794 len += sprintf(buf+len, "Remote only\n");
795 break;
796 case 0x03:
797 len += sprintf(buf+len, "Memory mapped and remote\n");
798 break;
799 default:
800 len += sprintf(buf+len, "Unknown\n");
801 break;
803 len += sprintf(buf+len, "Inbound Frame Size: %d bytes\n", work16[6]*4);
804 len += sprintf(buf+len, "Max Inbound Frames: %d\n", work32[4]);
805 len += sprintf(buf+len, "Current Inbound Frames: %d\n", work32[5]);
806 len += sprintf(buf+len, "Max Outbound Frames: %d\n", work32[6]);
808 /* Spec doesn't say if NULL terminated or not... */
809 memcpy(prodstr, work32+7, 24);
810 prodstr[24] = '\0';
811 len += sprintf(buf+len, "Product ID: %s\n", prodstr);
813 len += sprintf(buf+len, "LCT Size: %d\n", work32[13]);
815 len += sprintf(buf+len, "Desired private memory space: %d kB\n",
816 work32[15]>>10);
817 len += sprintf(buf+len, "Allocated private memory space: %d kB\n",
818 work32[16]>>10);
819 len += sprintf(buf+len, "Private memory base address: %0#10x\n",
820 work32[17]);
821 len += sprintf(buf+len, "Desired private I/O space: %d kB\n",
822 work32[18]>>10);
823 len += sprintf(buf+len, "Allocated private I/O space: %d kB\n",
824 work32[19]>>10);
825 len += sprintf(buf+len, "Private I/O base address: %0#10x\n",
826 work32[20]);
828 kfree(workspace);
829 spin_unlock(&i2o_proc_lock);
831 return len;
834 int i2o_proc_read_hw(char *buf, char **start, off_t offset, int len,
835 int *eof, void *data)
837 struct i2o_controller *c = (struct i2o_controller*)data;
838 static u32 work32[5];
839 static u8 *work8 = (u8*)work32;
840 static u16 *work16 = (u16*)work32;
841 int token;
842 u32 hwcap;
844 static char *cpu_table[] =
846 "Intel 80960 series",
847 "AMD2900 series",
848 "Motorola 68000 series",
849 "ARM series",
850 "MIPS series",
851 "Sparc series",
852 "PowerPC series",
853 "Intel x86 series"
856 spin_lock(&i2o_proc_lock);
858 len = 0;
860 token = i2o_query_scalar(c, ADAPTER_TID, proc_context,
861 0, // ParamGroup 0x0000h
862 -1, // all fields
863 &work32,
864 sizeof(work32),
865 &i2o_proc_token);
867 if(token < 0)
869 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
870 spin_unlock(&i2o_proc_lock);
871 return len;
874 len += sprintf(buf, "IOP Hardware Information Table (group = 0x0000)\n");
876 len += sprintf(buf+len, "I2O Vendor ID : %0#6x\n", work16[0]);
877 len += sprintf(buf+len, "Product ID : %0#6x\n", work16[1]);
878 len += sprintf(buf+len, "RAM : %dkB\n", work32[1]>>10);
879 len += sprintf(buf+len, "Non-Volatile Storage : %dkB\n", work32[2]>>10);
881 hwcap = work32[3];
882 len += sprintf(buf+len, "Capabilities :\n");
883 if(hwcap&0x00000001)
884 len += sprintf(buf+len, " Self-booting\n");
885 if(hwcap&0x00000002)
886 len += sprintf(buf+len, " Upgradable IRTOS\n");
887 if(hwcap&0x00000004)
888 len += sprintf(buf+len, " Supports downloading DDMs\n");
889 if(hwcap&0x00000008)
890 len += sprintf(buf+len, " Supports installing DDMs\n");
891 if(hwcap&0x00000010)
892 len += sprintf(buf+len, " Battery-backed RAM\n");
894 len += sprintf(buf+len, "CPU : ");
895 if(work8[16] > 8)
896 len += sprintf(buf+len, "Unknown\n");
897 else
898 len += sprintf(buf+len, "%s\n", cpu_table[work8[16]]);
899 /* Anyone using ProcessorVersion? */
901 spin_unlock(&i2o_proc_lock);
903 return len;
907 /* Executive group 0003h - Executing DDM List (table) */
908 int i2o_proc_read_ddm_table(char *buf, char **start, off_t offset, int len,
909 int *eof, void *data)
911 struct i2o_controller *c = (struct i2o_controller*)data;
912 int token;
913 int i;
915 typedef struct _i2o_exec_execute_ddm_table {
916 u16 ddm_tid;
917 u8 module_type;
918 u8 reserved;
919 u16 i2o_vendor_id;
920 u16 module_id;
921 u8 module_name[24];
922 u8 module_version[4];
923 u32 data_size;
924 u32 code_size;
925 } i2o_exec_execute_ddm_table, *pi2o_exec_execute_ddm_table;
927 struct
929 u16 result_count;
930 u16 pad;
931 u16 block_size;
932 u8 block_status;
933 u8 error_info_size;
934 u16 row_count;
935 u16 more_flag;
936 i2o_exec_execute_ddm_table ddm_table[MAX_I2O_MODULES];
937 } result;
939 i2o_exec_execute_ddm_table ddm_table;
941 spin_lock(&i2o_proc_lock);
942 len = 0;
944 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
945 c, ADAPTER_TID, proc_context,
946 0x0003, -1,
947 NULL, 0,
948 &result, sizeof(result), &i2o_proc_token);
950 if (token<0)
951 switch (token)
953 case -ETIMEDOUT:
954 len += sprintf(buf, "Timeout reading table.\n");
955 spin_unlock(&i2o_proc_lock);
956 return len;
957 break;
958 case -ENOMEM:
959 len += sprintf(buf, "No free memory to read the table.\n");
960 spin_unlock(&i2o_proc_lock);
961 return len;
962 break;
963 default:
964 len += sprintf(buf, "Error reading group. BlockStatus %d\n",
965 token);
966 spin_unlock(&i2o_proc_lock);
967 return len;
970 len += sprintf(buf+len, "Tid Type Vendor Id Name Vrs Data_size Code_size\n");
971 ddm_table=result.ddm_table[0];
973 for(i=0; i < result.row_count; ddm_table=result.ddm_table[++i])
975 len += sprintf(buf+len, "0x%03x ", ddm_table.ddm_tid & 0xFFF);
977 switch(ddm_table.module_type)
979 case 0x01:
980 len += sprintf(buf+len, "Downloaded DDM ");
981 break;
982 case 0x22:
983 len += sprintf(buf+len, "Embedded DDM ");
984 break;
985 default:
986 len += sprintf(buf+len, " ");
989 len += sprintf(buf+len, "%-0#7x", ddm_table.i2o_vendor_id);
990 len += sprintf(buf+len, "%-0#7x", ddm_table.module_id);
991 len += sprintf(buf+len, "%-25s", chtostr(ddm_table.module_name, 24));
992 len += sprintf(buf+len, "%-6s", chtostr(ddm_table.module_version,4));
993 len += sprintf(buf+len, "%8d ", ddm_table.data_size);
994 len += sprintf(buf+len, "%8d", ddm_table.code_size);
996 len += sprintf(buf+len, "\n");
999 spin_unlock(&i2o_proc_lock);
1001 return len;
1005 /* Executive group 0004h - Driver Store (scalar) */
1006 int i2o_proc_read_ds(char *buf, char **start, off_t offset, int len,
1007 int *eof, void *data)
1009 struct i2o_controller *c = (struct i2o_controller*)data;
1010 u32 work32[8];
1011 int token;
1013 spin_lock(&i2o_proc_lock);
1015 len = 0;
1017 token = i2o_query_scalar(c, ADAPTER_TID, proc_context, 0x0004, -1,
1018 &work32, sizeof(work32), &i2o_proc_token);
1020 if (token<0)
1022 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
1023 spin_unlock(&i2o_proc_lock);
1024 return len;
1027 len += sprintf(buf+len, "Module limit : %d\n"
1028 "Module count : %d\n"
1029 "Current space : %d kB\n"
1030 "Free space : %d kB\n",
1031 work32[0], work32[1], work32[2]>>10, work32[3]>>10);
1033 spin_unlock(&i2o_proc_lock);
1035 return len;
1039 /* Executive group 0005h - Driver Store Table (table) */
1040 int i2o_proc_read_dst(char *buf, char **start, off_t offset, int len,
1041 int *eof, void *data)
1043 typedef struct _i2o_driver_store {
1044 u16 stored_ddm_index;
1045 u8 module_type;
1046 u8 reserved;
1047 u16 i2o_vendor_id;
1048 u16 module_id;
1049 u8 module_name_version[28];
1050 u8 date[8];
1051 u32 module_size;
1052 u32 mpb_size;
1053 u32 module_flags;
1054 } i2o_driver_store_table;
1056 struct i2o_controller *c = (struct i2o_controller*)data;
1057 int token;
1058 int i;
1060 struct
1062 u16 result_count;
1063 u16 pad;
1064 u16 block_size;
1065 u8 block_status;
1066 u8 error_info_size;
1067 u16 row_count;
1068 u16 more_flag;
1069 i2o_driver_store_table dst[MAX_I2O_MODULES];
1070 } result;
1072 i2o_driver_store_table dst;
1074 spin_lock(&i2o_proc_lock);
1076 len = 0;
1078 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1079 c, ADAPTER_TID, proc_context,
1080 0x0005, -1,
1081 NULL, 0,
1082 &result, sizeof(result), &i2o_proc_token);
1084 if (token<0)
1085 switch (token)
1087 case -ETIMEDOUT:
1088 len += sprintf(buf, "Timeout reading table.\n");
1089 spin_unlock(&i2o_proc_lock);
1090 return len;
1091 break;
1092 case -ENOMEM:
1093 len += sprintf(buf, "No free memory to read the table.\n");
1094 spin_unlock(&i2o_proc_lock);
1095 return len;
1096 break;
1097 default:
1098 len += sprintf(buf, "Error reading group. "
1099 "BlockStatus %d\n",token);
1100 spin_unlock(&i2o_proc_lock);
1101 return len;
1104 len += sprintf(buf+len, "# Type Vendor Id Name Vrs Date Mod_size Par_size Flags\n");
1106 for(i=0, dst=result.dst[0]; i < result.row_count; dst=result.dst[++i])
1108 len += sprintf(buf+len, "%-3d", dst.stored_ddm_index);
1109 switch(dst.module_type)
1111 case 0x01:
1112 len += sprintf(buf+len, "Downloaded DDM ");
1113 break;
1114 case 0x22:
1115 len += sprintf(buf+len, "Embedded DDM ");
1116 break;
1117 default:
1118 len += sprintf(buf+len, " ");
1121 #if 0
1122 if(c->i2oversion == 0x02)
1123 len += sprintf(buf+len, "%-d", dst.module_state);
1124 #endif
1126 len += sprintf(buf+len, "%-0#7x", dst.i2o_vendor_id);
1127 len += sprintf(buf+len, "%-0#8x", dst.module_id);
1128 len += sprintf(buf+len, "%-29s", chtostr(dst.module_name_version,28));
1129 len += sprintf(buf+len, "%-9s", chtostr(dst.date,8));
1130 len += sprintf(buf+len, "%8d ", dst.module_size);
1131 len += sprintf(buf+len, "%8d ", dst.mpb_size);
1132 len += sprintf(buf+len, "0x%04x", dst.module_flags);
1133 #if 0
1134 if(c->i2oversion == 0x02)
1135 len += sprintf(buf+len, "%d",
1136 dst.notification_level);
1137 #endif
1138 len += sprintf(buf+len, "\n");
1141 spin_unlock(&i2o_proc_lock);
1143 return len;
1147 /* Generic group F000h - Params Descriptor (table) */
1148 int i2o_proc_read_groups(char *buf, char **start, off_t offset, int len,
1149 int *eof, void *data)
1151 struct i2o_controller *c = (struct i2o_controller*)data;
1152 int token;
1153 int i;
1154 int rows;
1155 u16 work16[2048];
1156 u16 *group=work16;
1157 int more;
1159 spin_lock(&i2o_proc_lock);
1161 len = 0;
1163 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1164 c, ADAPTER_TID, proc_context,
1165 0xF000, -1,
1166 NULL, 0,
1167 &work16, sizeof(work16), &i2o_proc_token);
1169 if (token<0)
1170 switch (token)
1172 case -ETIMEDOUT:
1173 len += sprintf(buf, "Timeout reading table.\n");
1174 spin_unlock(&i2o_proc_lock);
1175 return len;
1176 break;
1177 case -ENOMEM:
1178 len += sprintf(buf, "No free memory to read the table.\n");
1179 spin_unlock(&i2o_proc_lock);
1180 return len;
1181 break;
1182 default:
1183 len += sprintf(buf, "Error reading table. BlockStatus %d\n",
1184 token);
1185 spin_unlock(&i2o_proc_lock);
1186 return len;
1189 rows=work16[4];
1190 more=work16[5];
1192 len += sprintf(buf+len, "\nPARAMS DESCRIPTOR TABLE:\n\n");
1193 len += sprintf(buf+len, "# Group FieldCount RowCount Type Add Del Clear\n");
1195 group+=64;
1197 for(i=0; i < rows; i++, group+=16)
1199 len += sprintf(buf+len, "%-3d", i);
1201 len += sprintf(buf+len, "%-0#6x ", group[0]);
1202 len += sprintf(buf+len, "%10d ", group[1]);
1203 len += sprintf(buf+len, "%8d ", group[2]);
1205 if(group[3]&0x1)
1206 len += sprintf(buf+len, "Table ");
1207 else
1208 len += sprintf(buf+len, "Scalar ");
1209 if(group[3]&0x2)
1210 len += sprintf(buf+len, "x ");
1211 else
1212 len += sprintf(buf+len, " ");
1213 if(group[3]&0x4)
1214 len += sprintf(buf+len, "x ");
1215 else
1216 len += sprintf(buf+len, " ");
1217 if(group[3]&0x8)
1218 len += sprintf(buf+len, "x ");
1219 else
1220 len += sprintf(buf+len, " ");
1222 len += sprintf(buf+len, "\n");
1225 if(more)
1226 len += sprintf(buf+len, "There is more...\n");
1228 spin_unlock(&i2o_proc_lock);
1230 return len;
1234 /* Generic group F005h - Private message extensions (table) */
1235 int i2o_proc_read_priv_msgs(char *buf, char **start, off_t offset, int len,
1236 int *eof, void *data)
1238 struct i2o_controller *c = (struct i2o_controller*)data;
1239 int token;
1240 int i;
1241 int rows;
1242 int more;
1243 u16 work16[1024];
1244 u16 *field=work16;
1246 spin_lock(&i2o_proc_lock);
1248 len = 0;
1250 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1251 c, ADAPTER_TID, proc_context,
1252 0xF000, -1,
1253 NULL, 0,
1254 &work16, sizeof(work16), &i2o_proc_token);
1256 if (token<0)
1257 switch (token)
1259 case -ETIMEDOUT:
1260 len += sprintf(buf, "Timeout reading table.\n");
1261 spin_unlock(&i2o_proc_lock);
1262 return len;
1263 break;
1264 case -ENOMEM:
1265 len += sprintf(buf, "No free memory to read the table.\n");
1266 spin_unlock(&i2o_proc_lock);
1267 return len;
1268 break;
1269 default:
1270 len += sprintf(buf, "Error reading field. BlockStatus %d\n",
1271 token);
1272 spin_unlock(&i2o_proc_lock);
1273 return len;
1276 rows=work16[4];
1277 more=work16[5];
1279 len += sprintf(buf+len, "Instance# OrgId FunctionCode\n");
1281 field+=64;
1282 for(i=0; i < rows; i++, field+=16)
1284 len += sprintf(buf+len, "%0#9x ", field[0]);
1285 len += sprintf(buf+len, "%0#6x ", work16[1]);
1286 len += sprintf(buf+len, "%0#6x", work16[2]);
1288 len += sprintf(buf+len, "\n");
1291 if(more)
1292 len += sprintf(buf+len, "There is more...\n");
1294 spin_unlock(&i2o_proc_lock);
1296 return len;
1300 int i2o_proc_read_dev(char *buf, char **start, off_t offset, int len,
1301 int *eof, void *data)
1303 struct i2o_device *d = (struct i2o_device*)data;
1304 static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
1305 // == (allow) 512d bytes (max)
1306 static u16 *work16 = (u16*)work32;
1307 int token;
1309 spin_lock(&i2o_proc_lock);
1311 len = 0;
1313 token = i2o_query_scalar(d->controller, d->id, proc_context,
1314 0xF100, // ParamGroup F100h (Device Identity)
1315 -1, // all fields
1316 &work32,
1317 sizeof(work32),
1318 &i2o_proc_token);
1320 if(token < 0)
1322 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
1323 spin_unlock(&i2o_proc_lock);
1324 return len;
1327 len += sprintf(buf, "Device Class : %s\n", i2o_get_class_name(work16[0]));
1328 len += sprintf(buf+len, "Owner TID : %0#5x\n", work16[2]);
1329 len += sprintf(buf+len, "Parent TID : %0#5x\n", work16[3]);
1330 len += sprintf(buf+len, "Vendor info : %s\n", chtostr((u8 *)(work32+2), 16));
1331 len += sprintf(buf+len, "Product info : %s\n", chtostr((u8 *)(work32+6), 16));
1332 len += sprintf(buf+len, "Description : %s\n", chtostr((u8 *)(work32+10), 16));
1333 len += sprintf(buf+len, "Product rev. : %s\n", chtostr((u8 *)(work32+14), 8));
1335 len += sprintf(buf+len, "Serial number : ");
1336 len = print_serial_number(buf, len,
1337 (u8*)(work32+16),
1338 /* allow for SNLen plus
1339 * possible trailing '\0'
1341 sizeof(work32)-(16*sizeof(u32))-2
1343 len += sprintf(buf+len, "\n");
1345 spin_unlock(&i2o_proc_lock);
1347 return len;
1351 int i2o_proc_read_dev_name(char *buf, char **start, off_t offset, int len,
1352 int *eof, void *data)
1354 struct i2o_device *d = (struct i2o_device*)data;
1356 if ( d->dev_name[0] == '\0' )
1357 return 0;
1359 len = sprintf(buf, "%s\n", d->dev_name);
1361 return len;
1366 int i2o_proc_read_ddm(char *buf, char **start, off_t offset, int len,
1367 int *eof, void *data)
1369 struct i2o_device *d = (struct i2o_device*)data;
1370 static u32 work32[128];
1371 static u16 *work16 = (u16*)work32;
1372 int token;
1374 spin_lock(&i2o_proc_lock);
1376 len = 0;
1378 token = i2o_query_scalar(d->controller, d->id, proc_context,
1379 0xF101, // ParamGroup F101h (DDM Identity)
1380 -1, // all fields
1381 &work32,
1382 sizeof(work32),
1383 &i2o_proc_token);
1385 if(token < 0)
1387 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
1388 spin_unlock(&i2o_proc_lock);
1389 return len;
1392 len += sprintf(buf, "Registering DDM TID : 0x%03x\n", work16[0]&0xFFF);
1393 len += sprintf(buf+len, "Module name : %s\n", chtostr((u8 *)(work16+1), 24));
1394 len += sprintf(buf+len, "Module revision : %s\n", chtostr((u8 *)(work16+13), 8));
1396 len += sprintf(buf+len, "Serial number : ");
1397 len = print_serial_number(buf, len,
1398 (u8*)(work16+17),
1399 /* allow for SNLen plus
1400 * possible trailing '\0'
1402 sizeof(work32)-(17*sizeof(u16))-2
1404 len += sprintf(buf+len, "\n");
1406 spin_unlock(&i2o_proc_lock);
1408 return len;
1411 int i2o_proc_read_uinfo(char *buf, char **start, off_t offset, int len,
1412 int *eof, void *data)
1414 struct i2o_device *d = (struct i2o_device*)data;
1415 static u32 work32[256];
1416 int token;
1418 spin_lock(&i2o_proc_lock);
1420 len = 0;
1422 token = i2o_query_scalar(d->controller, d->id, proc_context,
1423 0xF102, // ParamGroup F102h (User Information)
1424 -1, // all fields
1425 &work32,
1426 sizeof(work32),
1427 &i2o_proc_token);
1429 if(token < 0)
1431 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
1432 spin_unlock(&i2o_proc_lock);
1433 return len;
1436 len += sprintf(buf, "Device name : %s\n", chtostr((u8 *)work32, 64));
1437 len += sprintf(buf+len, "Service name : %s\n", chtostr((u8 *)(work32+16), 64));
1438 len += sprintf(buf+len, "Physical name : %s\n", chtostr((u8 *)(work32+32), 64));
1439 len += sprintf(buf+len, "Instance number : %s\n", chtostr((u8 *)(work32+48), 4));
1441 spin_unlock(&i2o_proc_lock);
1443 return len;
1447 int i2o_proc_read_sgl_limits(char *buf, char **start, off_t offset, int len,
1448 int *eof, void *data)
1450 struct i2o_device *d = (struct i2o_device*)data;
1451 static u32 work32[12];
1452 static u16 *work16 = (u16 *)work32;
1453 static u8 *work8 = (u8 *)work32;
1454 int token;
1456 spin_lock(&i2o_proc_lock);
1458 len = 0;
1460 token = i2o_query_scalar(d->controller, d->id, proc_context,
1461 0xF103, // ParamGroup F103h (SGL Operating Limits)
1462 -1, // all fields
1463 &work32,
1464 sizeof(work32),
1465 &i2o_proc_token);
1467 if(token < 0)
1469 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
1470 spin_unlock(&i2o_proc_lock);
1471 return len;
1474 len += sprintf(buf, "SGL chain size : %d\n", work32[0]);
1475 len += sprintf(buf+len, "Max SGL chain size : %d\n", work32[1]);
1476 len += sprintf(buf+len, "SGL chain size target : %d\n", work32[2]);
1477 len += sprintf(buf+len, "SGL frag count : %d\n", work16[6]);
1478 len += sprintf(buf+len, "Max SGL frag count : %d\n", work16[7]);
1479 len += sprintf(buf+len, "SGL frag count target : %d\n", work16[8]);
1481 if (d->i2oversion == 0x02)
1483 len += sprintf(buf+len, "SGL data alignment : %d\n", work16[8]);
1484 len += sprintf(buf+len, "SGL addr limit : %d\n", work8[20]);
1485 len += sprintf(buf+len, "SGL addr sizes supported : ");
1486 if (work8[21] & 0x01)
1487 len += sprintf(buf+len, "32 bit ");
1488 if (work8[21] & 0x02)
1489 len += sprintf(buf+len, "64 bit ");
1490 if (work8[21] & 0x04)
1491 len += sprintf(buf+len, "96 bit ");
1492 if (work8[21] & 0x08)
1493 len += sprintf(buf+len, "128 bit ");
1494 len += sprintf(buf+len, "\n");
1497 spin_unlock(&i2o_proc_lock);
1499 return len;
1503 static int print_serial_number(char *buff, int pos, u8 *serialno, int max_len)
1505 int i;
1507 /* 19990419 -sralston
1508 * The I2O v1.5 (and v2.0 so far) "official specification"
1509 * got serial numbers WRONG!
1510 * Apparently, and despite what Section 3.4.4 says and
1511 * Figure 3-35 shows (pg 3-39 in the pdf doc),
1512 * the convention / consensus seems to be:
1513 * + First byte is SNFormat
1514 * + Second byte is SNLen (but only if SNFormat==7 (?))
1515 * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
1517 switch(serialno[0])
1519 case I2O_SNFORMAT_BINARY: /* Binary */
1520 pos += sprintf(buff+pos, "0x");
1521 for(i = 0; i < serialno[1]; i++)
1523 pos += sprintf(buff+pos, "%02X", serialno[2+i]);
1525 break;
1527 case I2O_SNFORMAT_ASCII: /* ASCII */
1528 if ( serialno[1] < ' ' ) /* printable or SNLen? */
1530 /* sanity */
1531 max_len = (max_len < serialno[1]) ? max_len : serialno[1];
1532 serialno[1+max_len] = '\0';
1534 /* just print it */
1535 pos += sprintf(buff+pos, "%s", &serialno[2]);
1537 else
1539 /* print chars for specified length */
1540 for(i = 0; i < serialno[1]; i++)
1542 pos += sprintf(buff+pos, "%c", serialno[2+i]);
1545 break;
1547 case I2O_SNFORMAT_UNICODE: /* UNICODE */
1548 pos += sprintf(buff+pos, "UNICODE Format. Can't Display\n");
1549 break;
1551 case I2O_SNFORMAT_LAN48_MAC: /* LAN-48 MAC Address */
1552 pos += sprintf(buff+pos,
1553 "LAN-48 MAC address @ %02X:%02X:%02X:%02X:%02X:%02X",
1554 serialno[2], serialno[3],
1555 serialno[4], serialno[5],
1556 serialno[6], serialno[7]);
1557 break;
1559 case I2O_SNFORMAT_WAN: /* WAN MAC Address */
1560 /* FIXME: Figure out what a WAN access address looks like?? */
1561 pos += sprintf(buff+pos, "WAN Access Address");
1562 break;
1564 /* plus new in v2.0 */
1565 case I2O_SNFORMAT_LAN64_MAC: /* LAN-64 MAC Address */
1566 /* FIXME: Figure out what a LAN-64 address really looks like?? */
1567 pos += sprintf(buff+pos,
1568 "LAN-64 MAC address @ [?:%02X:%02X:?] %02X:%02X:%02X:%02X:%02X:%02X",
1569 serialno[8], serialno[9],
1570 serialno[2], serialno[3],
1571 serialno[4], serialno[5],
1572 serialno[6], serialno[7]);
1573 break;
1576 case I2O_SNFORMAT_DDM: /* I2O DDM */
1577 pos += sprintf(buff+pos,
1578 "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
1579 *(u16*)&serialno[2],
1580 *(u16*)&serialno[4],
1581 *(u16*)&serialno[6]);
1582 break;
1584 case I2O_SNFORMAT_IEEE_REG64: /* IEEE Registered (64-bit) */
1585 case I2O_SNFORMAT_IEEE_REG128: /* IEEE Registered (128-bit) */
1586 /* FIXME: Figure if this is even close?? */
1587 pos += sprintf(buff+pos,
1588 "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n",
1589 *(u32*)&serialno[2],
1590 *(u32*)&serialno[6],
1591 *(u32*)&serialno[10],
1592 *(u32*)&serialno[14]);
1593 break;
1596 case I2O_SNFORMAT_UNKNOWN: /* Unknown 0 */
1597 case I2O_SNFORMAT_UNKNOWN2: /* Unknown 0xff */
1598 default:
1599 pos += sprintf(buff+pos, "Unknown data format (0x%02x)",
1600 serialno[0]);
1601 break;
1604 return pos;
1607 const char * i2o_get_connector_type(int conn)
1609 int idx = 16;
1610 static char *i2o_connector_type[] = {
1611 "OTHER",
1612 "UNKNOWN",
1613 "AUI",
1614 "UTP",
1615 "BNC",
1616 "RJ45",
1617 "STP DB9",
1618 "FIBER MIC",
1619 "APPLE AUI",
1620 "MII",
1621 "DB9",
1622 "HSSDC",
1623 "DUPLEX SC FIBER",
1624 "DUPLEX ST FIBER",
1625 "TNC/BNC",
1626 "HW DEFAULT"
1629 switch(conn)
1631 case 0x00000000:
1632 idx = 0;
1633 break;
1634 case 0x00000001:
1635 idx = 1;
1636 break;
1637 case 0x00000002:
1638 idx = 2;
1639 break;
1640 case 0x00000003:
1641 idx = 3;
1642 break;
1643 case 0x00000004:
1644 idx = 4;
1645 break;
1646 case 0x00000005:
1647 idx = 5;
1648 break;
1649 case 0x00000006:
1650 idx = 6;
1651 break;
1652 case 0x00000007:
1653 idx = 7;
1654 break;
1655 case 0x00000008:
1656 idx = 8;
1657 break;
1658 case 0x00000009:
1659 idx = 9;
1660 break;
1661 case 0x0000000A:
1662 idx = 10;
1663 break;
1664 case 0x0000000B:
1665 idx = 11;
1666 break;
1667 case 0x0000000C:
1668 idx = 12;
1669 break;
1670 case 0x0000000D:
1671 idx = 13;
1672 break;
1673 case 0x0000000E:
1674 idx = 14;
1675 break;
1676 case 0xFFFFFFFF:
1677 idx = 15;
1678 break;
1681 return i2o_connector_type[idx];
1685 const char * i2o_get_connection_type(int conn)
1687 int idx = 0;
1688 static char *i2o_connection_type[] = {
1689 "Unknown",
1690 "AUI",
1691 "10BASE5",
1692 "FIORL",
1693 "10BASE2",
1694 "10BROAD36",
1695 "10BASE-T",
1696 "10BASE-FP",
1697 "10BASE-FB",
1698 "10BASE-FL",
1699 "100BASE-TX",
1700 "100BASE-FX",
1701 "100BASE-T4",
1702 "1000BASE-SX",
1703 "1000BASE-LX",
1704 "1000BASE-CX",
1705 "1000BASE-T",
1706 "100VG-ETHERNET",
1707 "100VG-TOKEN RING",
1708 "4MBIT TOKEN RING",
1709 "16 Mb Token Ring",
1710 "125 MBAUD FDDI",
1711 "Point-to-point",
1712 "Arbitrated loop",
1713 "Public loop",
1714 "Fabric",
1715 "Emulation",
1716 "Other",
1717 "HW default"
1720 switch(conn)
1722 case I2O_LAN_UNKNOWN:
1723 idx = 0;
1724 break;
1725 case I2O_LAN_AUI:
1726 idx = 1;
1727 break;
1728 case I2O_LAN_10BASE5:
1729 idx = 2;
1730 break;
1731 case I2O_LAN_FIORL:
1732 idx = 3;
1733 break;
1734 case I2O_LAN_10BASE2:
1735 idx = 4;
1736 break;
1737 case I2O_LAN_10BROAD36:
1738 idx = 5;
1739 break;
1740 case I2O_LAN_10BASE_T:
1741 idx = 6;
1742 break;
1743 case I2O_LAN_10BASE_FP:
1744 idx = 7;
1745 break;
1746 case I2O_LAN_10BASE_FB:
1747 idx = 8;
1748 break;
1749 case I2O_LAN_10BASE_FL:
1750 idx = 9;
1751 break;
1752 case I2O_LAN_100BASE_TX:
1753 idx = 10;
1754 break;
1755 case I2O_LAN_100BASE_FX:
1756 idx = 11;
1757 break;
1758 case I2O_LAN_100BASE_T4:
1759 idx = 12;
1760 break;
1761 case I2O_LAN_1000BASE_SX:
1762 idx = 13;
1763 break;
1764 case I2O_LAN_1000BASE_LX:
1765 idx = 14;
1766 break;
1767 case I2O_LAN_1000BASE_CX:
1768 idx = 15;
1769 break;
1770 case I2O_LAN_1000BASE_T:
1771 idx = 16;
1772 break;
1773 case I2O_LAN_100VG_ETHERNET:
1774 idx = 17;
1775 break;
1776 case I2O_LAN_100VG_TR:
1777 idx = 18;
1778 break;
1779 case I2O_LAN_4MBIT:
1780 idx = 19;
1781 break;
1782 case I2O_LAN_16MBIT:
1783 idx = 20;
1784 break;
1785 case I2O_LAN_125MBAUD:
1786 idx = 21;
1787 break;
1788 case I2O_LAN_POINT_POINT:
1789 idx = 22;
1790 break;
1791 case I2O_LAN_ARB_LOOP:
1792 idx = 23;
1793 break;
1794 case I2O_LAN_PUBLIC_LOOP:
1795 idx = 24;
1796 break;
1797 case I2O_LAN_FABRIC:
1798 idx = 25;
1799 break;
1800 case I2O_LAN_EMULATION:
1801 idx = 26;
1802 break;
1803 case I2O_LAN_OTHER:
1804 idx = 27;
1805 break;
1806 case I2O_LAN_DEFAULT:
1807 idx = 28;
1808 break;
1811 return i2o_connection_type[idx];
1815 /* LAN group 0000h - Device info (scalar) */
1816 int i2o_proc_read_lan_dev_info(char *buf, char **start, off_t offset, int len,
1817 int *eof, void *data)
1819 struct i2o_device *d = (struct i2o_device*)data;
1820 static u32 work32[56];
1821 static u8 *work8 = (u8*)work32;
1822 static u16 *work16 = (u16*)work32;
1823 static u64 *work64 = (u64*)work32;
1824 int token;
1826 spin_lock(&i2o_proc_lock);
1828 len = 0;
1830 token = i2o_query_scalar(d->controller, d->id, proc_context,
1831 0x0000, -1, &work32, 56*4, &i2o_proc_token);
1832 if(token < 0)
1834 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
1835 spin_unlock(&i2o_proc_lock);
1836 return len;
1839 len += sprintf(buf, "LAN Type : ");
1840 switch (work16[0])
1842 case 0x0030:
1843 len += sprintf(buf+len, "Ethernet, ");
1844 break;
1845 case 0x0040:
1846 len += sprintf(buf+len, "100Base VG, ");
1847 break;
1848 case 0x0050:
1849 len += sprintf(buf+len, "Token Ring, ");
1850 break;
1851 case 0x0060:
1852 len += sprintf(buf+len, "FDDI, ");
1853 break;
1854 case 0x0070:
1855 len += sprintf(buf+len, "Fibre Channel, ");
1856 break;
1857 default:
1858 len += sprintf(buf+len, "Unknown type (0x%04x), ", work16[0]);
1859 break;
1862 if (work16[1]&0x00000001)
1863 len += sprintf(buf+len, "emulated LAN, ");
1864 else
1865 len += sprintf(buf+len, "physical LAN port, ");
1867 if (work16[1]&0x00000002)
1868 len += sprintf(buf+len, "full duplex\n");
1869 else
1870 len += sprintf(buf+len, "simplex\n");
1872 len += sprintf(buf+len, "Address format : ");
1873 switch(work8[4]) {
1874 case 0x00:
1875 len += sprintf(buf+len, "IEEE 48bit\n");
1876 break;
1877 case 0x01:
1878 len += sprintf(buf+len, "FC IEEE\n");
1879 break;
1880 default:
1881 len += sprintf(buf+len, "Unknown (0x%02x)\n", work8[4]);
1882 break;
1885 len += sprintf(buf+len, "State : ");
1886 switch(work8[5])
1888 case 0x00:
1889 len += sprintf(buf+len, "Unknown\n");
1890 break;
1891 case 0x01:
1892 len += sprintf(buf+len, "Unclaimed\n");
1893 break;
1894 case 0x02:
1895 len += sprintf(buf+len, "Operational\n");
1896 break;
1897 case 0x03:
1898 len += sprintf(buf+len, "Suspended\n");
1899 break;
1900 case 0x04:
1901 len += sprintf(buf+len, "Resetting\n");
1902 break;
1903 case 0x05:
1904 len += sprintf(buf+len, "ERROR: ");
1905 if(work16[3]&0x0001)
1906 len += sprintf(buf+len, "TxCU inoperative ");
1907 if(work16[3]&0x0002)
1908 len += sprintf(buf+len, "RxCU inoperative ");
1909 if(work16[3]&0x0004)
1910 len += sprintf(buf+len, "Local mem alloc ");
1911 len += sprintf(buf+len, "\n");
1912 break;
1913 case 0x06:
1914 len += sprintf(buf+len, "Operational no Rx\n");
1915 break;
1916 case 0x07:
1917 len += sprintf(buf+len, "Suspended no Rx\n");
1918 break;
1919 default:
1920 len += sprintf(buf+len, "Unspecified\n");
1921 break;
1924 len += sprintf(buf+len, "Min packet size : %d\n", work32[2]);
1925 len += sprintf(buf+len, "Max packet size : %d\n", work32[3]);
1926 len += sprintf(buf+len, "HW address : "
1927 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1928 work8[16],work8[17],work8[18],work8[19],
1929 work8[20],work8[21],work8[22],work8[23]);
1931 len += sprintf(buf+len, "Max Tx wire speed : %d bps\n", work64[3]);
1932 len += sprintf(buf+len, "Max Rx wire speed : %d bps\n", work64[4]);
1934 len += sprintf(buf+len, "Min SDU packet size : 0x%08x\n", work32[10]);
1935 len += sprintf(buf+len, "Max SDU packet size : 0x%08x\n", work32[11]);
1937 spin_unlock(&i2o_proc_lock);
1938 return len;
1941 /* LAN group 0001h - MAC address table (scalar) */
1942 int i2o_proc_read_lan_mac_addr(char *buf, char **start, off_t offset, int len,
1943 int *eof, void *data)
1945 struct i2o_device *d = (struct i2o_device*)data;
1946 static u32 work32[48];
1947 static u8 *work8 = (u8*)work32;
1948 int token;
1950 spin_lock(&i2o_proc_lock);
1951 len = 0;
1953 token = i2o_query_scalar(d->controller, d->id, proc_context,
1954 0x0001, -1, &work32, 48*4, &i2o_proc_token);
1955 if(token < 0)
1957 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
1958 spin_unlock(&i2o_proc_lock);
1959 return len;
1962 len += sprintf(buf, "Active address : "
1963 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1964 work8[0],work8[1],work8[2],work8[3],
1965 work8[4],work8[5],work8[6],work8[7]);
1966 len += sprintf(buf+len, "Current address : "
1967 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1968 work8[8],work8[9],work8[10],work8[11],
1969 work8[12],work8[13],work8[14],work8[15]);
1970 len += sprintf(buf+len, "Functional address mask : "
1971 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1972 work8[16],work8[17],work8[18],work8[19],
1973 work8[20],work8[21],work8[22],work8[23]);
1975 len += sprintf(buf+len, "HW/DDM capabilities : 0x%08x\n", work32[7]);
1976 len += sprintf(buf+len, " Unicast packets %ssupported\n",
1977 (work32[7]&0x00000001)?"":"not ");
1978 len += sprintf(buf+len, " Promiscuous mode %ssupported\n",
1979 (work32[7]&0x00000002)?"":"not");
1980 len += sprintf(buf+len, " Promiscuous multicast mode %ssupported\n",
1981 (work32[7]&0x00000004)?"":"not ");
1982 len += sprintf(buf+len," Broadcast reception disabling %ssupported\n",
1983 (work32[7]&0x00000100)?"":"not ");
1984 len += sprintf(buf+len," Multicast reception disabling %ssupported\n",
1985 (work32[7]&0x00000200)?"":"not ");
1986 len += sprintf(buf+len," Functional address disabling %ssupported\n",
1987 (work32[7]&0x00000400)?"":"not ");
1988 len += sprintf(buf+len, " MAC reporting %ssupported\n",
1989 (work32[7]&0x00000800)?"":"not ");
1991 len += sprintf(buf+len, "Filter mask : 0x%08x\n", work32[6]);
1992 len += sprintf(buf+len, " Unicast packets %s\n",
1993 (work32[6]&0x00000001)?"rejected":"enabled");
1994 len += sprintf(buf+len, " Promiscuous mode %s\n",
1995 (work32[6]&0x00000002)?"enabled":"disabled");
1996 len += sprintf(buf+len, " Promiscuous multicast mode %s\n",
1997 (work32[6]&0x00000004)?"enabled":"disabled");
1998 len += sprintf(buf+len, " Broadcast packets %s\n",
1999 (work32[6]&0x00000100)?"rejected":"enabled");
2000 len += sprintf(buf+len, " Multicast packets %s\n",
2001 (work32[6]&0x00000200)?"rejected":"enabled");
2002 len += sprintf(buf+len, " Functional address %s\n",
2003 (work32[6]&0x00000400)?"ignored":"enabled");
2005 if (work32[7]&0x00000800)
2007 len += sprintf(buf+len, " MAC reporting mode : ");
2008 if (work32[6]&0x00000800)
2009 len += sprintf(buf+len, "Pass only priority MAC packets to user\n");
2010 else if (work32[6]&0x00001000)
2011 len += sprintf(buf+len, "Pass all MAC packets to user\n");
2012 else if (work32[6]&0x00001800)
2013 len += sprintf(buf+len, "Pass all MAC packets (promiscuous) to user\n");
2014 else
2015 len += sprintf(buf+len, "Do not pass MAC packets to user\n");
2017 len += sprintf(buf+len, "Number of multicast addresses : %d\n", work32[8]);
2018 len += sprintf(buf+len, "Perfect filtering for max %d multicast addresses\n",
2019 work32[9]);
2020 len += sprintf(buf+len, "Imperfect filtering for max %d multicast addresses\n",
2021 work32[10]);
2023 spin_unlock(&i2o_proc_lock);
2025 return len;
2028 /* LAN group 0002h - Multicast MAC address table (table) */
2029 int i2o_proc_read_lan_mcast_addr(char *buf, char **start, off_t offset,
2030 int len, int *eof, void *data)
2032 struct i2o_device *d = (struct i2o_device*)data;
2033 static u32 field32[64];
2034 static u8 *field8 = (u8 *)field32;
2035 static u16 *field16 = (u16 *)field32;
2036 int token;
2037 int i;
2039 spin_lock(&i2o_proc_lock);
2040 len = 0;
2042 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
2043 d->controller, d->id, proc_context, 0x0002, -1,
2044 NULL, 0, &field32, sizeof(field32),
2045 &i2o_proc_token);
2047 if (token<0)
2048 switch (token) {
2049 case -ETIMEDOUT:
2050 len += sprintf(buf, "Timeout reading table.\n");
2051 spin_unlock(&i2o_proc_lock);
2052 return len;
2053 break;
2054 case -ENOMEM:
2055 len += sprintf(buf, "No free memory to read the table.\n");
2056 spin_unlock(&i2o_proc_lock);
2057 return len;
2058 break;
2059 default:
2060 len += sprintf(buf, "Error reading field. BlockStatus %d\n",
2061 token);
2062 spin_unlock(&i2o_proc_lock);
2063 return len;
2066 len += sprintf(buf, "RowCount=%d, MoreFlag=%d\n",
2067 field16[0], field16[1]);
2069 field8=(u8 *)&field16[2];
2071 for(i=0; i<field16[0]; i++, field8+=8)
2073 len += sprintf(buf+len, "MC MAC address[%d]: "
2074 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2076 field8[0], field8[1], field8[2],
2077 field8[3], field8[4], field8[5],
2078 field8[6], field8[7]);
2081 spin_unlock(&i2o_proc_lock);
2082 return len;
2085 /* LAN group 0003h - Batch Control (scalar) */
2086 int i2o_proc_read_lan_batch_control(char *buf, char **start, off_t offset,
2087 int len, int *eof, void *data)
2089 struct i2o_device *d = (struct i2o_device*)data;
2090 static u32 work32[9];
2091 int token;
2093 spin_lock(&i2o_proc_lock);
2094 len = 0;
2096 token = i2o_query_scalar(d->controller, d->id, proc_context,
2097 0x0003, -1, &work32, 9*4, &i2o_proc_token);
2098 if(token < 0)
2100 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2101 spin_unlock(&i2o_proc_lock);
2102 return len;
2105 len += sprintf(buf, "Batch mode ");
2106 if (work32[0]&0x00000001)
2107 len += sprintf(buf+len, "disabled");
2108 else
2109 len += sprintf(buf+len, "enabled");
2110 if (work32[0]&0x00000002)
2111 len += sprintf(buf+len, " (current setting)");
2112 if (work32[0]&0x00000004)
2113 len += sprintf(buf+len, ", forced");
2114 else
2115 len += sprintf(buf+len, ", toggle");
2116 len += sprintf(buf+len, "\n");
2118 if(d->i2oversion == 0x00) { /* Reserved in 1.53 and 2.0 */
2119 len += sprintf(buf+len, "Rising load delay : %d ms\n",
2120 work32[1]/10);
2121 len += sprintf(buf+len, "Rising load threshold : %d ms\n",
2122 work32[2]/10);
2123 len += sprintf(buf+len, "Falling load delay : %d ms\n",
2124 work32[3]/10);
2125 len += sprintf(buf+len, "Falling load threshold : %d ms\n",
2126 work32[4]/10);
2129 len += sprintf(buf+len, "Max Rx batch count : %d\n", work32[5]);
2130 len += sprintf(buf+len, "Max Rx batch delay : %d\n", work32[6]);
2132 if(d->i2oversion == 0x00) {
2133 len += sprintf(buf+len,
2134 "Transmission completion reporting delay : %d ms\n",
2135 work32[7]);
2136 } else {
2137 len += sprintf(buf+len, "Max Tx batch delay : %d\n", work32[7]);
2138 len += sprintf(buf+len, "Max Tx batch count : %d\n", work32[8]);
2141 spin_unlock(&i2o_proc_lock);
2142 return len;
2145 /* LAN group 0004h - LAN Operation (scalar) */
2146 int i2o_proc_read_lan_operation(char *buf, char **start, off_t offset, int len,
2147 int *eof, void *data)
2149 struct i2o_device *d = (struct i2o_device*)data;
2150 static u32 work32[5];
2151 int token;
2153 spin_lock(&i2o_proc_lock);
2154 len = 0;
2156 token = i2o_query_scalar(d->controller, d->id, proc_context,
2157 0x0004, -1, &work32, 20, &i2o_proc_token);
2158 if(token < 0)
2160 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2161 spin_unlock(&i2o_proc_lock);
2162 return len;
2165 len += sprintf(buf, "Packet prepadding (32b words) : %d\n", work32[0]);
2166 len += sprintf(buf+len, "Transmission error reporting : %s\n",
2167 (work32[1]&1)?"on":"off");
2168 len += sprintf(buf+len, "Bad packet handling : %s\n",
2169 (work32[1]&0x2)?"by host":"by DDM");
2170 len += sprintf(buf+len, "Packet orphan limit : %d\n", work32[2]);
2172 len += sprintf(buf+len, "Tx modes :\n");
2173 if (work32[3]&0x00000004)
2174 len += sprintf(buf+len, " HW CRC supressed\n");
2175 else
2176 len += sprintf(buf+len, " HW CRC\n");
2177 if (work32[3]&0x00000100)
2178 len += sprintf(buf+len, " HW IPv4 checksumming\n");
2179 if (work32[3]&0x00000200)
2180 len += sprintf(buf+len, " HW TCP checksumming\n");
2181 if (work32[3]&0x00000400)
2182 len += sprintf(buf+len, " HW UDP checksumming\n");
2183 if (work32[3]&0x00000800)
2184 len += sprintf(buf+len, " HW RSVP checksumming\n");
2185 if (work32[3]&0x00001000)
2186 len += sprintf(buf+len, " HW ICMP checksumming\n");
2187 if (work32[3]&0x00002000)
2188 len += sprintf(buf+len, " Loopback packet not delivered\n");
2190 len += sprintf(buf+len, "Rx modes :\n");
2191 if (work32[4]&0x00000004)
2192 len += sprintf(buf+len, " FCS in payload\n");
2193 if (work32[4]&0x00000100)
2194 len += sprintf(buf+len, " HW IPv4 checksum validation\n");
2195 if (work32[4]&0x00000200)
2196 len += sprintf(buf+len, " HW TCP checksum validation\n");
2197 if (work32[4]&0x00000400)
2198 len += sprintf(buf+len, " HW UDP checksum validation\n");
2199 if (work32[4]&0x00000800)
2200 len += sprintf(buf+len, " HW RSVP checksum validation\n");
2201 if (work32[4]&0x00001000)
2202 len += sprintf(buf+len, " HW ICMP checksum validation\n");
2204 spin_unlock(&i2o_proc_lock);
2205 return len;
2208 /* LAN group 0005h - Media operation (scalar) */
2209 int i2o_proc_read_lan_media_operation(char *buf, char **start, off_t offset,
2210 int len, int *eof, void *data)
2212 struct i2o_device *d = (struct i2o_device*)data;
2213 static u32 work32[9];
2214 static u8 *work8 = (u8*)work32;
2215 static u64 *work64 = (u64*)work32;
2216 int token;
2218 spin_lock(&i2o_proc_lock);
2219 len = 0;
2221 token = i2o_query_scalar(d->controller, d->id, proc_context,
2222 0x0005, -1, &work32, 36, &i2o_proc_token);
2223 if(token < 0)
2225 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2226 spin_unlock(&i2o_proc_lock);
2227 return len;
2230 len += sprintf(buf, "Connector type : %s\n",
2231 i2o_get_connector_type(work32[0]));
2232 len += sprintf(buf+len, "Connection type : %s\n",
2233 i2o_get_connection_type(work32[1]));
2235 len += sprintf(buf+len, "Current Tx wire speed : %d bps\n", work64[1]);
2236 len += sprintf(buf+len, "Current Rx wire speed : %d bps\n", work64[2]);
2238 len += sprintf(buf+len, "Duplex mode : %s duplex\n",
2239 (work8[24]&1)?"Full":"Half");
2240 len += sprintf(buf+len, "Link status : ");
2241 if(work8[25] == 0x00)
2242 len += sprintf(buf+len, "Unknown\n");
2243 else if(work8[25] == 0x01)
2244 len += sprintf(buf+len, "Normal\n");
2245 else if(work8[25] == 0x02)
2246 len += sprintf(buf+len, "Failure\n");
2247 else if(work8[25] == 0x03)
2248 len += sprintf(buf+len, "Reset\n");
2249 else
2250 len += sprintf(buf+len, "Unspecified\n");
2252 if (d->i2oversion == 0x00) { /* Reserved in 1.53 and 2.0 */
2253 len += sprintf(buf+len, "Bad packets handled by : %s\n",
2254 (work8[26] == 0xFF)?"host":"DDM");
2256 if (d->i2oversion != 0x00) {
2257 len += sprintf(buf+len, "Duplex mode target : ");
2258 switch (work8[27]) {
2259 case 0:
2260 len += sprintf(buf+len, "Half duplex\n");
2261 break;
2262 case 1:
2263 len += sprintf(buf+len, "Full duplex\n");
2264 break;
2265 default:
2266 len += sprintf(buf+len, "\n");
2267 break;
2270 len += sprintf(buf+len, "Connector type target : %s\n",
2271 i2o_get_connector_type(work32[7]));
2272 len += sprintf(buf+len, "Connection type target : %s\n",
2273 i2o_get_connection_type(work32[8]));
2276 spin_unlock(&i2o_proc_lock);
2277 return len;
2280 /* LAN group 0006h - Alternate address (table) */
2281 int i2o_proc_read_lan_alt_addr(char *buf, char **start, off_t offset, int len,
2282 int *eof, void *data)
2284 struct i2o_device *d = (struct i2o_device*)data;
2285 static u32 field32[64];
2286 static u8 *field8 = (u8 *)field32;
2287 static u16 *field16 = (u16 *)field32;
2288 int token;
2289 int i;
2291 spin_lock(&i2o_proc_lock);
2292 len = 0;
2294 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
2295 d->controller, d->id, proc_context, 0x0006, -1,
2296 NULL, 0, &field32, sizeof(field32),
2297 &i2o_proc_token);
2299 if (token<0)
2300 switch (token) {
2301 case -ETIMEDOUT:
2302 len += sprintf(buf, "Timeout reading table.\n");
2303 spin_unlock(&i2o_proc_lock);
2304 return len;
2305 break;
2306 case -ENOMEM:
2307 len += sprintf(buf, "No free memory to read the table.\n");
2308 spin_unlock(&i2o_proc_lock);
2309 return len;
2310 break;
2311 default:
2312 len += sprintf(buf, "Error reading field. BlockStatus %d\n",
2313 token);
2314 spin_unlock(&i2o_proc_lock);
2315 return len;
2318 len += sprintf(buf,"RowCount=%d, MoreFlag=%d\n", field16[0],
2319 field16[1]);
2321 field8=(u8 *)&field16[2];
2323 for(i=0; i<field16[0]; i++, field8+=8)
2325 len += sprintf(buf+len, "Alternate address[%d]: "
2326 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2328 field8[0], field8[1], field8[2],
2329 field8[3], field8[4], field8[5],
2330 field8[6], field8[7]);
2333 spin_unlock(&i2o_proc_lock);
2334 return len;
2338 /* LAN group 0007h - Transmit info (scalar) */
2339 int i2o_proc_read_lan_tx_info(char *buf, char **start, off_t offset, int len,
2340 int *eof, void *data)
2342 struct i2o_device *d = (struct i2o_device*)data;
2343 static u32 work32[8];
2344 int token;
2346 spin_lock(&i2o_proc_lock);
2347 len = 0;
2349 token = i2o_query_scalar(d->controller, d->id, proc_context,
2350 0x0007, -1, &work32, 8*4, &i2o_proc_token);
2351 if(token < 0)
2353 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2354 spin_unlock(&i2o_proc_lock);
2355 return len;
2358 len += sprintf(buf, "Max SG Elements per packet : %d\n", work32[0]);
2359 len += sprintf(buf+len, "Max SG Elements per chain : %d\n", work32[1]);
2360 len += sprintf(buf+len, "Max outstanding packets : %d\n", work32[2]);
2361 len += sprintf(buf+len, "Max packets per request : %d\n", work32[3]);
2363 len += sprintf(buf+len, "Tx modes :\n");
2364 if(work32[4]&0x00000002)
2365 len += sprintf(buf+len, " No DA in SGL\n");
2366 if(work32[4]&0x00000004)
2367 len += sprintf(buf+len, " CRC suppression\n");
2368 if(work32[4]&0x00000008)
2369 len += sprintf(buf+len, " Loop suppression\n");
2370 if(work32[4]&0x00000010)
2371 len += sprintf(buf+len, " MAC insertion\n");
2372 if(work32[4]&0x00000020)
2373 len += sprintf(buf+len, " RIF insertion\n");
2374 if(work32[4]&0x00000100)
2375 len += sprintf(buf+len, " IPv4 checksum\n");
2376 if(work32[4]&0x00000200)
2377 len += sprintf(buf+len, " TCP checksum\n");
2378 if(work32[4]&0x00000400)
2379 len += sprintf(buf+len, " UDP checksum\n");
2380 if(work32[4]&0x00000800)
2381 len += sprintf(buf+len, " RSVP checksum\n");
2382 if(work32[4]&0x00001000)
2383 len += sprintf(buf+len, " ICMP checksum\n");
2384 if (d->i2oversion == 0x00) {
2385 if(work32[4]&0x00008000)
2386 len += sprintf(buf+len, " Loopback enabled\n");
2387 if(work32[4]&0x00010000)
2388 len += sprintf(buf+len, " Loopback suppression enabled\n");
2389 } else {
2390 if(work32[4]&0x00010000)
2391 len += sprintf(buf+len, " Loopback enabled\n");
2392 if(work32[4]&0x00020000)
2393 len += sprintf(buf+len, " Loopback suppression enabled\n");
2396 spin_unlock(&i2o_proc_lock);
2397 return len;
2400 /* LAN group 0008h - Receive info (scalar) */
2401 int i2o_proc_read_lan_rx_info(char *buf, char **start, off_t offset, int len,
2402 int *eof, void *data)
2404 struct i2o_device *d = (struct i2o_device*)data;
2405 static u32 work32[8];
2406 int token;
2408 spin_lock(&i2o_proc_lock);
2409 len = 0;
2411 token = i2o_query_scalar(d->controller, d->id, proc_context,
2412 0x0008, -1, &work32, 8*4, &i2o_proc_token);
2413 if(token < 0)
2415 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2416 spin_unlock(&i2o_proc_lock);
2417 return len;
2420 len += sprintf(buf,"Max size of chain element : %d\n", work32[0]);
2421 len += sprintf(buf+len, "Max number of buckets : %d\n", work32[1]);
2423 if (d->i2oversion > 0x00) { /* not in 1.5 */
2424 len += sprintf(buf+len, "RxModes : %d\n", work32[2]);
2425 len += sprintf(buf+len, "RxMaxBucketsReply : %d\n", work32[3]);
2426 len += sprintf(buf+len, "RxMaxPacketsPerBuckets : %d\n", work32[4]);
2427 len += sprintf(buf+len, "RxMaxPostBuckets : %d\n", work32[5]);
2430 spin_unlock(&i2o_proc_lock);
2431 return len;
2435 /* LAN group 0100h - LAN Historical statistics (scalar) */
2436 int i2o_proc_read_lan_hist_stats(char *buf, char **start, off_t offset, int len,
2437 int *eof, void *data)
2439 struct i2o_device *d = (struct i2o_device*)data;
2440 static u64 work64[9];
2441 int token;
2443 spin_lock(&i2o_proc_lock);
2444 len = 0;
2446 token = i2o_query_scalar(d->controller, d->id, proc_context,
2447 0x0100, -1, &work64, 9*8, &i2o_proc_token);
2448 if(token < 0)
2450 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2451 spin_unlock(&i2o_proc_lock);
2452 return len;
2455 len += sprintf(buf, "Tx packets : " FMT_U64_HEX "\n",
2456 U64_VAL(&work64[0]));
2457 len += sprintf(buf+len, "Tx bytes : " FMT_U64_HEX "\n",
2458 U64_VAL(&work64[1]));
2459 len += sprintf(buf+len, "Rx packets : " FMT_U64_HEX "\n",
2460 U64_VAL(&work64[2]));
2461 len += sprintf(buf+len, "Rx bytes : " FMT_U64_HEX "\n",
2462 U64_VAL(&work64[3]));
2463 len += sprintf(buf+len, "Tx errors : " FMT_U64_HEX "\n",
2464 U64_VAL(&work64[4]));
2465 len += sprintf(buf+len, "Rx errors : " FMT_U64_HEX "\n",
2466 U64_VAL(&work64[5]));
2467 len += sprintf(buf+len, "Rx dropped : " FMT_U64_HEX "\n",
2468 U64_VAL(&work64[6]));
2469 len += sprintf(buf+len, "Adapter resets : " FMT_U64_HEX "\n",
2470 U64_VAL(&work64[7]));
2471 len += sprintf(buf+len, "Adapter suspends : " FMT_U64_HEX "\n",
2472 U64_VAL(&work64[8]));
2474 spin_unlock(&i2o_proc_lock);
2475 return len;
2479 /* LAN group 0180h - Supported Optional Historical Statistics (scalar) */
2480 int i2o_proc_read_lan_supp_opt_stats(char *buf, char **start, off_t offset,
2481 int len, int *eof, void *data)
2483 struct i2o_device *d = (struct i2o_device*)data;
2484 static u64 work64[4];
2485 int token;
2487 spin_lock(&i2o_proc_lock);
2489 len = 0;
2491 token = i2o_query_scalar(d->controller, d->id, proc_context,
2492 0x0180, -1, &work64, 4*8, &i2o_proc_token);
2493 if(token < 0)
2495 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2496 spin_unlock(&i2o_proc_lock);
2497 return len;
2500 if (d->i2oversion == 0x00)
2501 len += sprintf(buf, "Supported stats : " FMT_U64_HEX " \n",
2502 U64_VAL(&work64[0]));
2503 else
2505 len += sprintf(buf, "Supported stats (0182h) : " FMT_U64_HEX " \n",
2506 U64_VAL(&work64[1]));
2507 len += sprintf(buf, "Supported stats (0183h) : " FMT_U64_HEX " \n",
2508 U64_VAL(&work64[2]));
2509 len += sprintf(buf, "Supported stats (0184h) : " FMT_U64_HEX " \n",
2510 U64_VAL(&work64[3]));
2513 spin_unlock(&i2o_proc_lock);
2514 return len;
2518 /* LAN group 0182h - Optional Non Media Specific Transmit Historical Statistics
2519 * (scalar) */
2520 int i2o_proc_read_lan_opt_tx_hist_stats(char *buf, char **start, off_t offset,
2521 int len, int *eof, void *data)
2523 struct i2o_device *d = (struct i2o_device*)data;
2524 static u64 work64[9];
2525 int token;
2527 spin_lock(&i2o_proc_lock);
2529 len = 0;
2531 token = i2o_query_scalar(d->controller, d->id, proc_context,
2532 0x0182, -1, &work64, 9*8, &i2o_proc_token);
2533 if(token < 0)
2535 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2536 spin_unlock(&i2o_proc_lock);
2537 return len;
2540 len += sprintf(buf, "TxRetryCount : " FMT_U64_HEX "\n",
2541 U64_VAL(&work64[0]));
2542 len += sprintf(buf+len, "DirectedBytesTx : " FMT_U64_HEX "\n",
2543 U64_VAL(&work64[1]));
2544 len += sprintf(buf+len, "DirectedPacketsTx : " FMT_U64_HEX "\n",
2545 U64_VAL(&work64[2]));
2546 len += sprintf(buf+len, "MulticastBytesTx : " FMT_U64_HEX "\n",
2547 U64_VAL(&work64[3]));
2548 len += sprintf(buf+len, "MulticastPacketsTx : " FMT_U64_HEX "\n",
2549 U64_VAL(&work64[4]));
2550 len += sprintf(buf+len, "BroadcastBytesTx : " FMT_U64_HEX "\n",
2551 U64_VAL(&work64[5]));
2552 len += sprintf(buf+len, "BroadcastPacketsTx : " FMT_U64_HEX "\n",
2553 U64_VAL(&work64[6]));
2554 len += sprintf(buf+len, "TotalGroupAddrTxCount : " FMT_U64_HEX "\n",
2555 U64_VAL(&work64[7]));
2556 len += sprintf(buf+len, "TotalTxPacketsTooShort : " FMT_U64_HEX "\n",
2557 U64_VAL(&work64[8]));
2559 spin_unlock(&i2o_proc_lock);
2560 return len;
2563 /* LAN group 0183h - Optional Non Media Specific Receive Historical Statistics
2564 * (scalar) */
2565 int i2o_proc_read_lan_opt_rx_hist_stats(char *buf, char **start, off_t offset,
2566 int len, int *eof, void *data)
2568 struct i2o_device *d = (struct i2o_device*)data;
2569 static u64 work64[11];
2570 int token;
2572 spin_lock(&i2o_proc_lock);
2574 len = 0;
2576 token = i2o_query_scalar(d->controller, d->id, proc_context,
2577 0x0183, -1, &work64, 11*8, &i2o_proc_token);
2578 if(token < 0)
2580 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2581 spin_unlock(&i2o_proc_lock);
2582 return len;
2585 len += sprintf(buf, "ReceiveCRCErrorCount : " FMT_U64_HEX "\n",
2586 U64_VAL(&work64[0]));
2587 len += sprintf(buf+len, "DirectedBytesRx : " FMT_U64_HEX "\n",
2588 U64_VAL(&work64[1]));
2589 len += sprintf(buf+len, "DirectedPacketsRx : " FMT_U64_HEX "\n",
2590 U64_VAL(&work64[2]));
2591 len += sprintf(buf+len, "MulticastBytesRx : " FMT_U64_HEX "\n",
2592 U64_VAL(&work64[3]));
2593 len += sprintf(buf+len, "MulticastPacketsRx : " FMT_U64_HEX "\n",
2594 U64_VAL(&work64[4]));
2595 len += sprintf(buf+len, "BroadcastBytesRx : " FMT_U64_HEX "\n",
2596 U64_VAL(&work64[5]));
2597 len += sprintf(buf+len, "BroadcastPacketsRx : " FMT_U64_HEX "\n",
2598 U64_VAL(&work64[6]));
2599 len += sprintf(buf+len, "TotalGroupAddrRxCount : " FMT_U64_HEX "\n",
2600 U64_VAL(&work64[7]));
2601 len += sprintf(buf+len, "TotalRxPacketsTooShort : " FMT_U64_HEX "\n",
2602 U64_VAL(&work64[8]));
2603 len += sprintf(buf+len, "TotalRxPacketsTooLong : " FMT_U64_HEX "\n",
2604 U64_VAL(&work64[9]));
2605 len += sprintf(buf+len, "TotalRuntPacketsReceived : " FMT_U64_HEX "\n",
2606 U64_VAL(&work64[10]));
2608 spin_unlock(&i2o_proc_lock);
2609 return len;
2612 /* LAN group 0200h - Required Ethernet Statistics (scalar) */
2613 int i2o_proc_read_lan_eth_stats(char *buf, char **start, off_t offset,
2614 int len, int *eof, void *data)
2616 struct i2o_device *d = (struct i2o_device*)data;
2617 static u64 work64[8];
2618 int token;
2621 spin_lock(&i2o_proc_lock);
2623 len = 0;
2625 token = i2o_query_scalar(d->controller, d->id, proc_context,
2626 0x0200, -1, &work64, 8*8, &i2o_proc_token);
2627 if(token < 0)
2629 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2630 spin_unlock(&i2o_proc_lock);
2631 return len;
2634 len += sprintf(buf, "Rx alignment errors : " FMT_U64_HEX "\n",
2635 U64_VAL(&work64[0]));
2636 len += sprintf(buf+len, "Tx one collisions : " FMT_U64_HEX "\n",
2637 U64_VAL(&work64[1]));
2638 len += sprintf(buf+len, "Tx multicollisions : " FMT_U64_HEX "\n",
2639 U64_VAL(&work64[2]));
2640 len += sprintf(buf+len, "Tx deferred : " FMT_U64_HEX "\n",
2641 U64_VAL(&work64[3]));
2642 len += sprintf(buf+len, "Tx late collisions : " FMT_U64_HEX "\n",
2643 U64_VAL(&work64[4]));
2644 len += sprintf(buf+len, "Tx max collisions : " FMT_U64_HEX "\n",
2645 U64_VAL(&work64[5]));
2646 len += sprintf(buf+len, "Tx carrier lost : " FMT_U64_HEX "\n",
2647 U64_VAL(&work64[6]));
2648 len += sprintf(buf+len, "Tx excessive deferrals : " FMT_U64_HEX "\n",
2649 U64_VAL(&work64[7]));
2651 spin_unlock(&i2o_proc_lock);
2652 return len;
2655 /* LAN group 0280h - Supported Ethernet Historical Statistics (scalar) */
2656 int i2o_proc_read_lan_supp_eth_stats(char *buf, char **start, off_t offset,
2657 int len, int *eof, void *data)
2659 struct i2o_device *d = (struct i2o_device*)data;
2660 static u64 work64[1];
2661 int token;
2663 spin_lock(&i2o_proc_lock);
2665 len = 0;
2667 token = i2o_query_scalar(d->controller, d->id, proc_context,
2668 0x0280, -1, &work64, 8, &i2o_proc_token);
2669 if(token < 0)
2671 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2672 spin_unlock(&i2o_proc_lock);
2673 return len;
2676 len += sprintf(buf, "Supported stats : " FMT_U64_HEX "\n",
2677 U64_VAL(&work64[0]));
2679 spin_unlock(&i2o_proc_lock);
2680 return len;
2683 /* LAN group 0281h - Optional Ethernet Historical Statistics (scalar) */
2684 int i2o_proc_read_lan_opt_eth_stats(char *buf, char **start, off_t offset,
2685 int len, int *eof, void *data)
2687 struct i2o_device *d = (struct i2o_device*)data;
2688 static u64 work64[3];
2689 int token;
2691 spin_lock(&i2o_proc_lock);
2693 len = 0;
2695 token = i2o_query_scalar(d->controller, d->id, proc_context,
2696 0x0281, -1, &work64, 3*8, &i2o_proc_token);
2697 if(token < 0)
2699 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2700 spin_unlock(&i2o_proc_lock);
2701 return len;
2704 len += sprintf(buf, "Rx overrun : " FMT_U64_HEX "\n",
2705 U64_VAL(&work64[0]));
2706 len += sprintf(buf, "Tx underrun : " FMT_U64_HEX "\n",
2707 U64_VAL(&work64[1]));
2708 len += sprintf(buf, "Tx heartbeat failure : " FMT_U64_HEX "\n",
2709 U64_VAL(&work64[2]));
2711 spin_unlock(&i2o_proc_lock);
2712 return len;
2715 /* LAN group 0300h - Required Token Ring Statistics (scalar) */
2716 int i2o_proc_read_lan_tr_stats(char *buf, char **start, off_t offset,
2717 int len, int *eof, void *data)
2719 struct i2o_device *d = (struct i2o_device*)data;
2720 static u64 work64[13];
2721 int token;
2723 static char *ring_status[] =
2730 "Ring Recovery",
2731 "Single Station",
2732 "Counter Overflow",
2733 "Remove Received",
2735 "Auto-Removal Error 1",
2736 "Lobe Wire Fault",
2737 "Transmit Beacon",
2738 "Soft Error",
2739 "Hard Error",
2740 "Signal Loss"
2743 spin_lock(&i2o_proc_lock);
2745 len = 0;
2747 token = i2o_query_scalar(d->controller, d->id, proc_context,
2748 0x0300, -1, &work64, 13*8, &i2o_proc_token);
2749 if(token < 0)
2751 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2752 spin_unlock(&i2o_proc_lock);
2753 return len;
2756 len += sprintf(buf, "LineErrors : " FMT_U64_HEX "\n",
2757 U64_VAL(&work64[0]));
2758 len += sprintf(buf+len, "LostFrames : " FMT_U64_HEX "\n",
2759 U64_VAL(&work64[1]));
2760 len += sprintf(buf+len, "ACError : " FMT_U64_HEX "\n",
2761 U64_VAL(&work64[2]));
2762 len += sprintf(buf+len, "TxAbortDelimiter : " FMT_U64_HEX "\n",
2763 U64_VAL(&work64[3]));
2764 len += sprintf(buf+len, "BursErrors : " FMT_U64_HEX "\n",
2765 U64_VAL(&work64[4]));
2766 len += sprintf(buf+len, "FrameCopiedErrors : " FMT_U64_HEX "\n",
2767 U64_VAL(&work64[5]));
2768 len += sprintf(buf+len, "FrequencyErrors : " FMT_U64_HEX "\n",
2769 U64_VAL(&work64[6]));
2770 len += sprintf(buf+len, "InternalErrors : " FMT_U64_HEX "\n",
2771 U64_VAL(&work64[7]));
2772 len += sprintf(buf+len, "LastRingStatus : %s\n", ring_status[work64[8]]);
2773 len += sprintf(buf+len, "TokenError : " FMT_U64_HEX "\n",
2774 U64_VAL(&work64[9]));
2775 len += sprintf(buf+len, "UpstreamNodeAddress : " FMT_U64_HEX "\n",
2776 U64_VAL(&work64[10]));
2777 len += sprintf(buf+len, "LastRingID : " FMT_U64_HEX "\n",
2778 U64_VAL(&work64[11]));
2779 len += sprintf(buf+len, "LastBeaconType : " FMT_U64_HEX "\n",
2780 U64_VAL(&work64[12]));
2782 spin_unlock(&i2o_proc_lock);
2783 return len;
2786 /* LAN group 0400h - Required FDDI Statistics (scalar) */
2787 int i2o_proc_read_lan_fddi_stats(char *buf, char **start, off_t offset,
2788 int len, int *eof, void *data)
2790 struct i2o_device *d = (struct i2o_device*)data;
2791 static u64 work64[11];
2792 int token;
2794 static char *conf_state[] =
2796 "Isolated",
2797 "Local a",
2798 "Local b",
2799 "Local ab",
2800 "Local s",
2801 "Wrap a",
2802 "Wrap b",
2803 "Wrap ab",
2804 "Wrap s",
2805 "C-Wrap a",
2806 "C-Wrap b",
2807 "C-Wrap s",
2808 "Through",
2811 static char *ring_state[] =
2813 "Isolated",
2814 "Non-op",
2815 "Rind-op",
2816 "Detect",
2817 "Non-op-Dup",
2818 "Ring-op-Dup",
2819 "Directed",
2820 "Trace"
2823 static char *link_state[] =
2825 "Off",
2826 "Break",
2827 "Trace",
2828 "Connect",
2829 "Next",
2830 "Signal",
2831 "Join",
2832 "Verify",
2833 "Active",
2834 "Maintenance"
2837 spin_lock(&i2o_proc_lock);
2839 len = 0;
2841 token = i2o_query_scalar(d->controller, d->id, proc_context,
2842 0x0400, -1, &work64, 11*8, &i2o_proc_token);
2843 if(token < 0)
2845 len += sprintf(buf, "Timeout waiting for reply from IOP\n");
2846 spin_unlock(&i2o_proc_lock);
2847 return len;
2850 len += sprintf(buf, "ConfigurationState : %s\n", conf_state[work64[0]]);
2851 len += sprintf(buf+len, "UpstreamNode : " FMT_U64_HEX "\n",
2852 U64_VAL(&work64[1]));
2853 len += sprintf(buf+len, "DownStreamNode : " FMT_U64_HEX "\n",
2854 U64_VAL(&work64[2]));
2855 len += sprintf(buf+len, "FrameErrors : " FMT_U64_HEX "\n",
2856 U64_VAL(&work64[3]));
2857 len += sprintf(buf+len, "FramesLost : " FMT_U64_HEX "\n",
2858 U64_VAL(&work64[4]));
2859 len += sprintf(buf+len, "RingMgmtState : %s\n", ring_state[work64[5]]);
2860 len += sprintf(buf+len, "LCTFailures: " FMT_U64_HEX "\n",
2861 U64_VAL(&work64[6]));
2862 len += sprintf(buf+len, "LEMRejects : " FMT_U64_HEX "\n",
2863 U64_VAL(&work64[7]));
2864 len += sprintf(buf+len, "LEMCount : " FMT_U64_HEX "\n",
2865 U64_VAL(&work64[8]));
2866 len += sprintf(buf+len, "LConnectionState : %s\n",
2867 link_state[work64[9]]);
2869 spin_unlock(&i2o_proc_lock);
2870 return len;
2873 static int i2o_proc_create_entries(void *data, i2o_proc_entry *pentry,
2874 struct proc_dir_entry *parent)
2876 struct proc_dir_entry *ent;
2878 while(pentry->name != NULL)
2880 ent = create_proc_entry(pentry->name, pentry->mode, parent);
2881 if(!ent) return -1;
2883 ent->data = data;
2884 ent->read_proc = pentry->read_proc;
2885 ent->write_proc = pentry->write_proc;
2886 ent->nlink = 1;
2888 pentry++;
2891 return 0;
2894 static void i2o_proc_remove_entries(i2o_proc_entry *pentry,
2895 struct proc_dir_entry *parent)
2897 while(pentry->name != NULL)
2899 remove_proc_entry(pentry->name, parent);
2900 pentry++;
2904 static int i2o_proc_add_controller(struct i2o_controller *pctrl,
2905 struct proc_dir_entry *root )
2907 struct proc_dir_entry *dir, *dir1;
2908 struct i2o_device *dev;
2909 char buff[10];
2911 sprintf(buff, "iop%d", pctrl->unit);
2913 dir = create_proc_entry(buff, S_IFDIR, root);
2914 if(!dir)
2915 return -1;
2917 pctrl->proc_entry = dir;
2919 i2o_proc_create_entries(pctrl, generic_iop_entries, dir);
2921 for(dev = pctrl->devices; dev; dev = dev->next)
2923 sprintf(buff, "%0#5x", dev->id);
2925 dir1 = create_proc_entry(buff, S_IFDIR, dir);
2926 dev->proc_entry = dir1;
2928 if(!dir1)
2929 printk(KERN_INFO "i2o_proc: Could not allocate proc dir\n");
2931 i2o_proc_create_entries(dev, generic_dev_entries, dir1);
2933 switch(dev->class)
2935 case I2O_CLASS_SCSI_PERIPHERAL:
2936 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
2937 i2o_proc_create_entries(dev, rbs_dev_entries, dir1);
2938 break;
2939 case I2O_CLASS_LAN:
2940 i2o_proc_create_entries(dev, lan_entries, dir1);
2941 switch(dev->subclass)
2943 case I2O_LAN_ETHERNET:
2944 i2o_proc_create_entries(dev, lan_eth_entries,
2945 dir1);
2946 break;
2947 case I2O_LAN_FDDI:
2948 i2o_proc_create_entries(dev, lan_fddi_entries,
2949 dir1);
2950 break;
2951 case I2O_LAN_TR:
2952 i2o_proc_create_entries(dev, lan_tr_entries,
2953 dir1);
2954 break;
2955 default:
2956 break;
2958 break;
2959 default:
2960 break;
2964 return 0;
2967 static void i2o_proc_remove_controller(struct i2o_controller *pctrl,
2968 struct proc_dir_entry *parent)
2970 char buff[10];
2971 char dev_id[10];
2972 struct proc_dir_entry *de;
2973 struct i2o_device *dev;
2975 /* Remove unused device entries */
2976 for(dev=pctrl->devices; dev; dev=dev->next)
2978 de=dev->proc_entry;
2979 sprintf(dev_id, "%0#5x", dev->id);
2981 /* Would it be safe to remove _files_ even if they are in use? */
2982 if((de) && (!de->count))
2984 i2o_proc_remove_entries(generic_dev_entries, de);
2986 switch(dev->class)
2988 case I2O_CLASS_SCSI_PERIPHERAL:
2989 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
2990 i2o_proc_remove_entries(rbs_dev_entries, de);
2991 break;
2992 case I2O_CLASS_LAN:
2993 i2o_proc_remove_entries(lan_entries, de);
2994 switch(dev->subclass)
2996 case I2O_LAN_ETHERNET:
2997 i2o_proc_remove_entries(lan_eth_entries, de);
2998 break;
2999 case I2O_LAN_FDDI:
3000 i2o_proc_remove_entries(lan_fddi_entries, de);
3001 break;
3002 case I2O_LAN_TR:
3003 i2o_proc_remove_entries(lan_tr_entries, de);
3004 break;
3007 remove_proc_entry(dev_id, parent);
3011 if(!pctrl->proc_entry->count)
3013 sprintf(buff, "iop%d", pctrl->unit);
3015 i2o_proc_remove_entries(generic_iop_entries, pctrl->proc_entry);
3017 remove_proc_entry(buff, parent);
3018 pctrl->proc_entry = NULL;
3022 static int create_i2o_procfs(void)
3024 struct i2o_controller *pctrl = NULL;
3025 int i;
3027 i2o_proc_dir_root = create_proc_entry("i2o", S_IFDIR, 0);
3028 if(!i2o_proc_dir_root)
3029 return -1;
3031 for(i = 0; i < MAX_I2O_CONTROLLERS; i++)
3033 pctrl = i2o_find_controller(i);
3034 if(pctrl)
3036 i2o_proc_add_controller(pctrl, i2o_proc_dir_root);
3037 i2o_unlock_controller(pctrl);
3041 return 0;
3044 static int destroy_i2o_procfs(void)
3046 struct i2o_controller *pctrl = NULL;
3047 int i;
3049 if(!i2o_find_controller(0))
3050 return -1;
3052 for(i = 0; i < MAX_I2O_CONTROLLERS; i++)
3054 pctrl = i2o_find_controller(i);
3055 if(pctrl)
3057 i2o_proc_remove_controller(pctrl, i2o_proc_dir_root);
3058 i2o_unlock_controller(pctrl);
3062 if(!i2o_proc_dir_root->count)
3063 remove_proc_entry("i2o", 0);
3064 else
3065 return -1;
3067 return 0;
3070 #ifdef MODULE
3071 #define i2o_proc_init init_module
3072 #endif
3074 __init int i2o_proc_init(void)
3076 if(create_i2o_procfs())
3077 return -EBUSY;
3079 if (i2o_install_handler(&i2o_proc_handler) < 0)
3081 printk(KERN_ERR "i2o_proc: Unable to install PROC handler.\n");
3082 return 0;
3085 proc_context = i2o_proc_handler.context;
3087 return 0;
3090 #ifdef MODULE
3093 MODULE_AUTHOR("Deepak Saxena");
3094 MODULE_DESCRIPTION("I2O procfs Handler");
3096 void cleanup_module(void)
3098 destroy_i2o_procfs();
3099 i2o_remove_handler(&i2o_proc_handler);
3101 #endif