2 * procfs handler for Linux I2O subsystem
4 * Copyright (c) 1999 Intel Corporation
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/config.h>
42 #include <linux/types.h>
43 #include <linux/kernel.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>
51 #include <asm/uaccess.h>
52 #include <asm/byteorder.h>
53 #include <asm/spinlock.h>
61 * Structure used to define /proc entries
63 typedef struct _i2o_proc_entry_t
65 char *name
; /* entry name */
66 mode_t mode
; /* mode */
67 read_proc_t
*read_proc
; /* read func */
68 write_proc_t
*write_proc
; /* write func */
71 static int proc_context
= 0;
74 static int i2o_proc_read_lct(char *, char **, off_t
, int, int *, void *);
75 static int i2o_proc_read_hrt(char *, char **, off_t
, int, int *, void *);
76 static int i2o_proc_read_stat(char *, char **, off_t
, int, int *, void *);
77 static int i2o_proc_read_hw(char *, char **, off_t
, int, int *, void *);
78 static int i2o_proc_read_dst(char *, char **, off_t
, int, int *, void *);
79 static int i2o_proc_read_ddm_table(char *, char **, off_t
, int, int *, void *);
80 static int i2o_proc_read_ds(char *, char **, off_t
, int, int *, void *);
81 static int i2o_proc_read_groups(char *, char **, off_t
, int, int *, void *);
82 static int i2o_proc_read_priv_msgs(char *, char **, off_t
, int, int *, void *);
83 static int i2o_proc_read_dev(char *, char **, off_t
, int, int *, void *);
84 static int i2o_proc_read_dev_name(char *, char **, off_t
, int, int *, void *);
85 static int i2o_proc_read_ddm(char *, char **, off_t
, int, int *, void *);
86 static int i2o_proc_read_uinfo(char *, char **, off_t
, int, int *, void *);
87 static int i2o_proc_read_sgl_limits(char *, char **, off_t
, int, int *, void *);
88 static int print_serial_number(char *, int, u8
*, int);
89 static int i2o_proc_create_entries(void *,
90 i2o_proc_entry
*, struct proc_dir_entry
*);
91 static void i2o_proc_remove_entries(i2o_proc_entry
*, struct proc_dir_entry
*);
92 static int i2o_proc_add_controller(struct i2o_controller
*,
93 struct proc_dir_entry
* );
94 static void i2o_proc_remove_controller(struct i2o_controller
*,
95 struct proc_dir_entry
* );
96 static int create_i2o_procfs(void);
97 static int destroy_i2o_procfs(void);
98 static void i2o_proc_reply(struct i2o_handler
*, struct i2o_controller
*,
99 struct i2o_message
*);
101 static int i2o_proc_read_lan_dev_info(char *, char **, off_t
, int, int *,
103 static int i2o_proc_read_lan_mac_addr(char *, char **, off_t
, int, int *,
105 static int i2o_proc_read_lan_mcast_addr(char *, char **, off_t
, int, int *,
107 static int i2o_proc_read_lan_batch_control(char *, char **, off_t
, int, int *,
109 static int i2o_proc_read_lan_operation(char *, char **, off_t
, int, int *,
111 static int i2o_proc_read_lan_media_operation(char *, char **, off_t
, int,
113 static int i2o_proc_read_lan_alt_addr(char *, char **, off_t
, int, int *,
115 static int i2o_proc_read_lan_tx_info(char *, char **, off_t
, int, int *,
117 static int i2o_proc_read_lan_rx_info(char *, char **, off_t
, int, int *,
119 static int i2o_proc_read_lan_hist_stats(char *, char **, off_t
, int, int *,
121 static int i2o_proc_read_lan_supp_opt_stats(char *, char **, off_t
, int, int *,
123 static int i2o_proc_read_lan_opt_tx_hist_stats(char *, char **, off_t
, int,
125 static int i2o_proc_read_lan_opt_rx_hist_stats(char *, char **, off_t
, int,
127 static int i2o_proc_read_lan_eth_stats(char *, char **, off_t
, int,
129 static int i2o_proc_read_lan_supp_eth_stats(char *, char **, off_t
, int, int *,
131 static int i2o_proc_read_lan_opt_eth_stats(char *, char **, off_t
, int, 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
=
145 (void *)i2o_proc_reply
,
148 0xffffffff // All classes
152 * IOP specific entries...write field just in case someone
155 static i2o_proc_entry generic_iop_entries
[] =
157 {"hrt", S_IFREG
|S_IRUGO
, i2o_proc_read_hrt
, NULL
},
158 {"lct", S_IFREG
|S_IRUGO
, i2o_proc_read_lct
, NULL
},
159 {"stat", S_IFREG
|S_IRUGO
, i2o_proc_read_stat
, NULL
},
160 {"hw", S_IFREG
|S_IRUGO
, i2o_proc_read_hw
, NULL
},
161 {"dst", S_IFREG
|S_IRUGO
, i2o_proc_read_dst
, NULL
},
162 {"ddm_table", S_IFREG
|S_IRUGO
, i2o_proc_read_ddm_table
, NULL
},
163 {"ds", S_IFREG
|S_IRUGO
, i2o_proc_read_ds
, NULL
},
164 {NULL
, 0, NULL
, NULL
}
168 * Device specific entries
170 static i2o_proc_entry generic_dev_entries
[] =
172 {"groups", S_IFREG
|S_IRUGO
, i2o_proc_read_groups
, NULL
},
173 {"priv_msgs", S_IFREG
|S_IRUGO
, i2o_proc_read_priv_msgs
, NULL
},
174 {"dev_identity", S_IFREG
|S_IRUGO
, i2o_proc_read_dev
, NULL
},
175 {"ddm_identity", S_IFREG
|S_IRUGO
, i2o_proc_read_ddm
, NULL
},
176 {"sgl_limits", S_IFREG
|S_IRUGO
, i2o_proc_read_sgl_limits
, NULL
},
177 {"user_info", S_IFREG
|S_IRUGO
, i2o_proc_read_uinfo
, NULL
},
178 {NULL
, 0, NULL
, NULL
}
182 * Storage unit specific entries (SCSI Periph, BS) with device names
184 static i2o_proc_entry rbs_dev_entries
[] =
186 {"dev_name", S_IFREG
|S_IRUGO
, i2o_proc_read_dev_name
, NULL
},
187 {NULL
, 0, NULL
, NULL
}
190 #define SCSI_TABLE_SIZE 13
191 static char *scsi_devices
[] =
193 "Direct-Access Read/Write",
194 "Sequential-Access Storage",
200 "Optical Memory Device",
201 "Medium Changer Device",
202 "Communications Device",
203 "Graphics Art Pre-Press Device",
204 "Graphics Art Pre-Press Device",
205 "Array Controller Device"
211 * Generic LAN specific entries
213 * Should groups with r/w entries have their own subdirectory?
216 static i2o_proc_entry lan_entries
[] =
218 /* LAN param groups 0000h-0008h */
219 {"lan_dev_info", S_IFREG
|S_IRUGO
, i2o_proc_read_lan_dev_info
, NULL
},
220 {"lan_mac_addr", S_IFREG
|S_IRUGO
, i2o_proc_read_lan_mac_addr
, NULL
},
221 {"lan_mcast_addr", S_IFREG
|S_IRUGO
|S_IWUSR
,
222 i2o_proc_read_lan_mcast_addr
, NULL
},
223 {"lan_batch_ctrl", S_IFREG
|S_IRUGO
|S_IWUSR
,
224 i2o_proc_read_lan_batch_control
, NULL
},
225 {"lan_operation", S_IFREG
|S_IRUGO
, i2o_proc_read_lan_operation
, NULL
},
226 {"lan_media_operation", S_IFREG
|S_IRUGO
,
227 i2o_proc_read_lan_media_operation
, NULL
},
228 {"lan_alt_addr", S_IFREG
|S_IRUGO
, i2o_proc_read_lan_alt_addr
, NULL
},
229 {"lan_tx_info", S_IFREG
|S_IRUGO
, i2o_proc_read_lan_tx_info
, NULL
},
230 {"lan_rx_info", S_IFREG
|S_IRUGO
, i2o_proc_read_lan_rx_info
, NULL
},
231 /* LAN param groups 0100h, 0180h, 0182h, 0183h */
232 {"lan_stats", S_IFREG
|S_IRUGO
, i2o_proc_read_lan_hist_stats
, NULL
},
233 {"lan_supp_opt_stats", S_IFREG
|S_IRUGO
,
234 i2o_proc_read_lan_supp_opt_stats
, NULL
},
235 {"lan_opt_tx_stats", S_IFREG
|S_IRUGO
,
236 i2o_proc_read_lan_opt_tx_hist_stats
, NULL
},
237 {"lan_opt_rx_stats", S_IFREG
|S_IRUGO
,
238 i2o_proc_read_lan_opt_rx_hist_stats
, NULL
},
239 /* TODO: LAN param group 0184h */
240 {NULL
, 0, NULL
, NULL
}
244 * Ethernet specific LAN entries
247 static i2o_proc_entry lan_eth_entries
[] =
249 /* LAN param groups 0200h, 0280h, 0281h */
250 {"lan_eth_stat", S_IFREG
|S_IRUGO
, i2o_proc_read_lan_eth_stats
, NULL
},
251 {"lan_supp_eth_stats", S_IFREG
|S_IRUGO
,
252 i2o_proc_read_lan_supp_eth_stats
, NULL
},
253 {"lan_opt_eth_stats", S_IFREG
|S_IRUGO
,
254 i2o_proc_read_lan_opt_eth_stats
, NULL
},
255 {NULL
, 0, NULL
, NULL
}
259 * Token Ring specific LAN entries
262 static i2o_proc_entry lan_tr_entries
[] =
264 /* LAN param group 0300h */
265 {"lan_tr_stats", S_IFREG
|S_IRUGO
,
266 i2o_proc_read_lan_tr_stats
, NULL
},
267 /* TODO: LAN param group 0380h, 0381h */
268 {NULL
, 0, NULL
, NULL
}
272 * FDDI specific LAN entries
275 static i2o_proc_entry lan_fddi_entries
[] =
277 /* LAN param group 0400h */
278 {"lan_fddi_stats", S_IFREG
|S_IRUGO
,
279 i2o_proc_read_lan_fddi_stats
, NULL
},
280 /* TODO: LAN param group 0480h, 0481h */
281 {NULL
, 0, NULL
, NULL
}
285 static u32 i2o_proc_token
= 0;
287 static char *chtostr(u8
*chars
, int n
)
291 return strncat(tmp
, (char *)chars
, n
);
294 static char* bus_strings
[] =
306 static spinlock_t i2o_proc_lock
= SPIN_LOCK_UNLOCKED
;
308 void i2o_proc_reply(struct i2o_handler
*phdlr
, struct i2o_controller
*pctrl
,
309 struct i2o_message
*pmsg
)
311 i2o_proc_token
= I2O_POST_WAIT_OK
;
314 int i2o_proc_read_hrt(char *buf
, char **start
, off_t offset
, int len
,
315 int *eof
, void *data
)
317 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
326 spin_lock(&i2o_proc_lock
);
330 workspace
= kmalloc(2048, GFP_KERNEL
);
331 hrt
= (pi2o_hrt
)workspace
;
334 len
+= sprintf(buf
, "No free memory for HRT buffer\n");
335 spin_unlock(&i2o_proc_lock
);
339 memset(workspace
, 0, 2048);
341 msg
[0]= SIX_WORD_MSG_SIZE
| SGL_OFFSET_4
;
342 msg
[1]= I2O_CMD_HRT_GET
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
343 msg
[2]= (u32
)proc_context
;
345 msg
[4]= (0xD0000000 | 2048);
346 msg
[5]= virt_to_phys(workspace
);
348 token
= i2o_post_wait(c
, ADAPTER_TID
, msg
, 6*4, &i2o_proc_token
,2);
349 if(token
== I2O_POST_WAIT_TIMEOUT
)
352 len
+= sprintf(buf
, "Timeout waiting for HRT\n");
353 spin_unlock(&i2o_proc_lock
);
360 len
+= sprintf(buf
+len
,
361 "HRT table for controller is too new a version.\n");
362 spin_unlock(&i2o_proc_lock
);
366 count
= hrt
->num_entries
;
368 if((count
* hrt
->entry_len
+ 8) > 2048) {
369 printk(KERN_WARNING
"i2o_proc: HRT does not fit into buffer\n");
371 len
+= sprintf(buf
+len
,
372 "HRT table too big to fit in buffer.\n");
373 spin_unlock(&i2o_proc_lock
);
377 len
+= sprintf(buf
+len
, "HRT has %d entries of %d bytes each.\n",
378 count
, hrt
->entry_len
);
380 for(i
= 0; i
< count
; i
++)
382 len
+= sprintf(buf
+len
, "Entry %d:\n", i
);
383 len
+= sprintf(buf
+len
, " Adapter ID: %0#10x\n",
384 hrt
->hrt_entry
[i
].adapter_id
);
385 len
+= sprintf(buf
+len
, " Controlled by: %0#6x\n",
386 hrt
->hrt_entry
[i
].parent_tid
);
387 len
+= sprintf(buf
+len
, " Bus#%d\n",
388 hrt
->hrt_entry
[i
].bus_num
);
390 if(hrt
->hrt_entry
[i
].bus_type
!= 0x80)
392 bus
= hrt
->hrt_entry
[i
].bus_type
;
393 len
+= sprintf(buf
+len
, " %s Information\n", bus_strings
[bus
]);
398 len
+= sprintf(buf
+len
, " IOBase: %0#6x,",
399 hrt
->hrt_entry
[i
].bus
.local_bus
.LbBaseIOPort
);
400 len
+= sprintf(buf
+len
, " MemoryBase: %0#10x\n",
401 hrt
->hrt_entry
[i
].bus
.local_bus
.LbBaseMemoryAddress
);
405 len
+= sprintf(buf
+len
, " IOBase: %0#6x,",
406 hrt
->hrt_entry
[i
].bus
.isa_bus
.IsaBaseIOPort
);
407 len
+= sprintf(buf
+len
, " MemoryBase: %0#10x,",
408 hrt
->hrt_entry
[i
].bus
.isa_bus
.IsaBaseMemoryAddress
);
409 len
+= sprintf(buf
+len
, " CSN: %0#4x,",
410 hrt
->hrt_entry
[i
].bus
.isa_bus
.CSN
);
414 len
+= sprintf(buf
+len
, " IOBase: %0#6x,",
415 hrt
->hrt_entry
[i
].bus
.eisa_bus
.EisaBaseIOPort
);
416 len
+= sprintf(buf
+len
, " MemoryBase: %0#10x,",
417 hrt
->hrt_entry
[i
].bus
.eisa_bus
.EisaBaseMemoryAddress
);
418 len
+= sprintf(buf
+len
, " Slot: %0#4x,",
419 hrt
->hrt_entry
[i
].bus
.eisa_bus
.EisaSlotNumber
);
423 len
+= sprintf(buf
+len
, " IOBase: %0#6x,",
424 hrt
->hrt_entry
[i
].bus
.mca_bus
.McaBaseIOPort
);
425 len
+= sprintf(buf
+len
, " MemoryBase: %0#10x,",
426 hrt
->hrt_entry
[i
].bus
.mca_bus
.McaBaseMemoryAddress
);
427 len
+= sprintf(buf
+len
, " Slot: %0#4x,",
428 hrt
->hrt_entry
[i
].bus
.mca_bus
.McaSlotNumber
);
432 len
+= sprintf(buf
+len
, " Bus: %0#4x",
433 hrt
->hrt_entry
[i
].bus
.pci_bus
.PciBusNumber
);
434 len
+= sprintf(buf
+len
, " Dev: %0#4x",
435 hrt
->hrt_entry
[i
].bus
.pci_bus
.PciDeviceNumber
);
436 len
+= sprintf(buf
+len
, " Func: %0#4x",
437 hrt
->hrt_entry
[i
].bus
.pci_bus
.PciFunctionNumber
);
438 len
+= sprintf(buf
+len
, " Vendor: %0#6x",
439 hrt
->hrt_entry
[i
].bus
.pci_bus
.PciVendorID
);
440 len
+= sprintf(buf
+len
, " Device: %0#6x\n",
441 hrt
->hrt_entry
[i
].bus
.pci_bus
.PciDeviceID
);
445 len
+= sprintf(buf
+len
, " Unsupported Bus Type\n");
449 len
+= sprintf(buf
+len
, " Unknown Bus Type\n");
454 spin_unlock(&i2o_proc_lock
);
459 int i2o_proc_read_lct(char *buf
, char **start
, off_t offset
, int len
,
460 int *eof
, void *data
)
462 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
465 pi2o_lct lct
; /* = (pi2o_lct)c->lct; */
470 #define BUS_TABLE_SIZE 3
471 static char *bus_ports
[] =
478 spin_lock(&i2o_proc_lock
);
482 workspace
= kmalloc(8192, GFP_KERNEL
);
483 lct
= (pi2o_lct
)workspace
;
486 len
+= sprintf(buf
, "No free memory for LCT buffer\n");
487 spin_unlock(&i2o_proc_lock
);
491 memset(workspace
, 0, 8192);
493 msg
[0] = FOUR_WORD_MSG_SIZE
|SGL_OFFSET_6
;
494 msg
[1] = I2O_CMD_LCT_NOTIFY
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
495 msg
[2] = (u32
)proc_context
;
497 msg
[4] = 0xFFFFFFFF; /* All devices */
498 msg
[5] = 0x00000000; /* Report now */
499 msg
[6] = 0xD0000000|8192;
500 msg
[7] = virt_to_bus(workspace
);
502 token
= i2o_post_wait(c
, ADAPTER_TID
, msg
, 8*4, &i2o_proc_token
,2);
503 if(token
== I2O_POST_WAIT_TIMEOUT
)
506 len
+= sprintf(buf
, "Timeout waiting for LCT\n");
507 spin_unlock(&i2o_proc_lock
);
511 entries
= (lct
->table_size
- 3)/9;
513 len
+= sprintf(buf
, "LCT contains %d %s\n", entries
,
514 entries
== 1 ? "entry" : "entries");
516 len
+= sprintf(buf
+len
, "Boot Device @ ID %d\n", lct
->boot_tid
);
518 for(i
= 0; i
< entries
; i
++)
520 len
+= sprintf(buf
+len
, "Entry %d\n", i
);
522 len
+= sprintf(buf
+len
, " %s", i2o_get_class_name(lct
->lct_entry
[i
].class_id
));
525 * Classes which we'll print subclass info for
527 switch(lct
->lct_entry
[i
].class_id
& 0xFFF)
529 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
530 switch(lct
->lct_entry
[i
].sub_class
)
533 len
+= sprintf(buf
+len
, ": Direct-Access Read/Write");
537 len
+= sprintf(buf
+len
, ": WORM Drive");
541 len
+= sprintf(buf
+len
, ": CD-ROM Drive");
545 len
+= sprintf(buf
+len
, ": Optical Memory Device");
549 len
+= sprintf(buf
+len
, ": Unknown (0x%02x)",
550 lct
->lct_entry
[i
].sub_class
);
556 switch(lct
->lct_entry
[i
].sub_class
& 0xFF)
559 len
+= sprintf(buf
+len
, ": Ethernet");
563 len
+= sprintf(buf
+len
, ": 100base VG");
567 len
+= sprintf(buf
+len
, ": IEEE 802.5/Token-Ring");
571 len
+= sprintf(buf
+len
, ": ANSI X3T9.5 FDDI");
575 len
+= sprintf(buf
+len
, ": Fibre Channel");
579 len
+= sprintf(buf
+len
, ": Unknown Sub-Class (0x%02x)",
580 lct
->lct_entry
[i
].sub_class
& 0xFF);
585 case I2O_CLASS_SCSI_PERIPHERAL
:
586 if(lct
->lct_entry
[i
].sub_class
< SCSI_TABLE_SIZE
)
587 len
+= sprintf(buf
+len
, ": %s",
588 scsi_devices
[lct
->lct_entry
[i
].sub_class
]);
590 len
+= sprintf(buf
+len
, ": Unknown Device Type");
593 case I2O_CLASS_BUS_ADAPTER_PORT
:
594 if(lct
->lct_entry
[i
].sub_class
< BUS_TABLE_SIZE
)
595 len
+= sprintf(buf
+len
, ": %s",
596 bus_ports
[lct
->lct_entry
[i
].sub_class
]);
598 len
+= sprintf(buf
+len
, ": Unknown Bus Type");
601 len
+= sprintf(buf
+len
, "\n");
603 len
+= sprintf(buf
+len
, " Local TID: 0x%03x\n", lct
->lct_entry
[i
].tid
);
604 len
+= sprintf(buf
+len
, " User TID: 0x%03x\n", lct
->lct_entry
[i
].user_tid
);
605 len
+= sprintf(buf
+len
, " Parent TID: 0x%03x\n",
606 lct
->lct_entry
[i
].parent_tid
);
607 len
+= sprintf(buf
+len
, " Identity Tag: 0x%x%x%x%x%x%x%x%x\n",
608 lct
->lct_entry
[i
].identity_tag
[0],
609 lct
->lct_entry
[i
].identity_tag
[1],
610 lct
->lct_entry
[i
].identity_tag
[2],
611 lct
->lct_entry
[i
].identity_tag
[3],
612 lct
->lct_entry
[i
].identity_tag
[4],
613 lct
->lct_entry
[i
].identity_tag
[5],
614 lct
->lct_entry
[i
].identity_tag
[6],
615 lct
->lct_entry
[i
].identity_tag
[7]);
616 len
+= sprintf(buf
+len
, " Change Indicator: %0#10x\n",
617 lct
->lct_entry
[i
].change_ind
);
618 len
+= sprintf(buf
+len
, " Device Flags: %0#10x\n",
619 lct
->lct_entry
[i
].device_flags
);
623 spin_unlock(&i2o_proc_lock
);
628 int i2o_proc_read_stat(char *buf
, char **start
, off_t offset
, int len
,
629 int *eof
, void *data
)
631 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
641 spin_lock(&i2o_proc_lock
);
645 workspace
= (u8
*)kmalloc(88, GFP_KERNEL
);
648 len
+= sprintf(buf
, "No memory for status transfer\n");
649 spin_unlock(&i2o_proc_lock
);
653 m
= I2O_POST_READ32(c
);
656 len
+= sprintf(buf
, "Could not get inbound message frame from IOP!\n");
658 spin_unlock(&i2o_proc_lock
);
662 msg
= (u32
*)(m
+c
->mem_offset
);
664 memset(workspace
, 0, 88);
665 work32
= (u32
*)workspace
;
666 work16
= (u16
*)workspace
;
668 msg
[0] = NINE_WORD_MSG_SIZE
|SGL_OFFSET_0
;
669 msg
[1] = I2O_CMD_STATUS_GET
<<24|HOST_TID
<<12|ADAPTER_TID
;
670 msg
[2] = msg
[3] = msg
[4] = msg
[5] = 0;
671 msg
[6] = virt_to_phys(workspace
);
672 msg
[7] = 0; /* FIXME: 64-bit */
676 * hmm...i2o_post_message should just take ptr to message, and
677 * determine offset on it's own...less work for OSM developers
679 i2o_post_message(c
, m
);
683 while(workspace
[87] != 0xFF)
685 if(jiffies
-time
>= 2*HZ
)
687 len
+= sprintf(buf
, "Timeout waiting for status reply\n");
689 spin_unlock(&i2o_proc_lock
);
696 len
+= sprintf(buf
+len
, "Organization ID: %0#6x\n", work16
[0]);
698 version
= workspace
[9]&0xF0>>4;
699 if(version
== 0x02) {
700 len
+= sprintf(buf
+len
, "Lowest I2O version supported: ");
701 switch(workspace
[2]) {
703 len
+= sprintf(buf
+len
, "1.0\n");
706 len
+= sprintf(buf
+len
, "1.5\n");
709 len
+= sprintf(buf
+len
, "2.0\n");
713 len
+= sprintf(buf
+len
, "Highest I2O version supported: ");
714 switch(workspace
[3]) {
716 len
+= sprintf(buf
+len
, "1.0\n");
719 len
+= sprintf(buf
+len
, "1.5\n");
722 len
+= sprintf(buf
+len
, "2.0\n");
727 len
+= sprintf(buf
+len
, "IOP ID: %0#5x\n", work16
[2]&0xFFF);
728 len
+= sprintf(buf
+len
, "Host Unit ID: %0#6x\n", work16
[3]);
729 len
+= sprintf(buf
+len
, "Segment Number: %0#5x\n", work16
[4]&0XFFF);
731 len
+= sprintf(buf
+len
, "I2O version: ");
735 len
+= sprintf(buf
+len
, "1.0\n");
738 len
+= sprintf(buf
+len
, "1.5\n");
741 len
+= sprintf(buf
+len
, "2.0\n");
744 len
+= sprintf(buf
+len
, "Unknown version\n");
747 len
+= sprintf(buf
+len
, "IOP State: ");
748 switch(workspace
[10])
751 len
+= sprintf(buf
+len
, "Init\n");
755 len
+= sprintf(buf
+len
, "Reset\n");
759 len
+= sprintf(buf
+len
, "Hold\n");
763 len
+= sprintf(buf
+len
, "Hold\n");
767 len
+= sprintf(buf
+len
, "Operational\n");
771 len
+= sprintf(buf
+len
, "FAILED\n");
775 len
+= sprintf(buf
+len
, "FAULTED\n");
779 len
+= sprintf(buf
+len
, "Unknown\n");
783 /* 0x00 is the only type supported w/spec 1.5 */
784 /* Added 2.0 types */
785 len
+= sprintf(buf
+len
, "Messenger Type: ");
786 switch (workspace
[11])
789 len
+= sprintf(buf
+len
, "Memory mapped\n");
792 len
+= sprintf(buf
+len
, "Memory mapped only\n");
795 len
+= sprintf(buf
+len
, "Remote only\n");
798 len
+= sprintf(buf
+len
, "Memory mapped and remote\n");
801 len
+= sprintf(buf
+len
, "Unknown\n");
804 len
+= sprintf(buf
+len
, "Inbound Frame Size: %d bytes\n", work16
[6]*4);
805 len
+= sprintf(buf
+len
, "Max Inbound Frames: %d\n", work32
[4]);
806 len
+= sprintf(buf
+len
, "Current Inbound Frames: %d\n", work32
[5]);
807 len
+= sprintf(buf
+len
, "Max Outbound Frames: %d\n", work32
[6]);
809 /* Spec doesn't say if NULL terminated or not... */
810 memcpy(prodstr
, work32
+7, 24);
812 len
+= sprintf(buf
+len
, "Product ID: %s\n", prodstr
);
814 len
+= sprintf(buf
+len
, "LCT Size: %d\n", work32
[13]);
816 len
+= sprintf(buf
+len
, "Desired private memory space: %d kB\n",
818 len
+= sprintf(buf
+len
, "Allocated private memory space: %d kB\n",
820 len
+= sprintf(buf
+len
, "Private memory base address: %0#10x\n",
822 len
+= sprintf(buf
+len
, "Desired private I/O space: %d kB\n",
824 len
+= sprintf(buf
+len
, "Allocated private I/O space: %d kB\n",
826 len
+= sprintf(buf
+len
, "Private I/O base address: %0#10x\n",
830 spin_unlock(&i2o_proc_lock
);
835 int i2o_proc_read_hw(char *buf
, char **start
, off_t offset
, int len
,
836 int *eof
, void *data
)
838 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
839 static u32 work32
[5];
840 static u8
*work8
= (u8
*)work32
;
841 static u16
*work16
= (u16
*)work32
;
845 static char *cpu_table
[] =
847 "Intel 80960 series",
849 "Motorola 68000 series",
857 spin_lock(&i2o_proc_lock
);
861 token
= i2o_query_scalar(c
, ADAPTER_TID
, proc_context
,
862 0, // ParamGroup 0x0000h
870 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
871 spin_unlock(&i2o_proc_lock
);
875 len
+= sprintf(buf
, "IOP Hardware Information Table (group = 0x0000)\n");
877 len
+= sprintf(buf
+len
, "I2O Vendor ID : %0#6x\n", work16
[0]);
878 len
+= sprintf(buf
+len
, "Product ID : %0#6x\n", work16
[1]);
879 len
+= sprintf(buf
+len
, "RAM : %dkB\n", work32
[1]>>10);
880 len
+= sprintf(buf
+len
, "Non-Volatile Storage : %dkB\n", work32
[2]>>10);
883 len
+= sprintf(buf
+len
, "Capabilities :\n");
885 len
+= sprintf(buf
+len
, " Self-booting\n");
887 len
+= sprintf(buf
+len
, " Upgradable IRTOS\n");
889 len
+= sprintf(buf
+len
, " Supports downloading DDMs\n");
891 len
+= sprintf(buf
+len
, " Supports installing DDMs\n");
893 len
+= sprintf(buf
+len
, " Battery-backed RAM\n");
895 len
+= sprintf(buf
+len
, "CPU : ");
897 len
+= sprintf(buf
+len
, "Unknown\n");
899 len
+= sprintf(buf
+len
, "%s\n", cpu_table
[work8
[16]]);
900 /* Anyone using ProcessorVersion? */
902 spin_unlock(&i2o_proc_lock
);
908 /* Executive group 0003h - Executing DDM List (table) */
909 int i2o_proc_read_ddm_table(char *buf
, char **start
, off_t offset
, int len
,
910 int *eof
, void *data
)
912 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
916 typedef struct _i2o_exec_execute_ddm_table
{
923 u8 module_version
[4];
926 } i2o_exec_execute_ddm_table
, *pi2o_exec_execute_ddm_table
;
937 i2o_exec_execute_ddm_table ddm_table
[MAX_I2O_MODULES
];
940 i2o_exec_execute_ddm_table ddm_table
;
942 spin_lock(&i2o_proc_lock
);
945 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
946 c
, ADAPTER_TID
, proc_context
,
949 &result
, sizeof(result
), &i2o_proc_token
);
955 len
+= sprintf(buf
, "Timeout reading table.\n");
956 spin_unlock(&i2o_proc_lock
);
960 len
+= sprintf(buf
, "No free memory to read the table.\n");
961 spin_unlock(&i2o_proc_lock
);
965 len
+= sprintf(buf
, "Error reading group. BlockStatus %d\n",
967 spin_unlock(&i2o_proc_lock
);
971 len
+= sprintf(buf
+len
, "Tid Type Vendor Id Name Vrs Data_size Code_size\n");
972 ddm_table
=result
.ddm_table
[0];
974 for(i
=0; i
< result
.row_count
; ddm_table
=result
.ddm_table
[++i
])
976 len
+= sprintf(buf
+len
, "0x%03x ", ddm_table
.ddm_tid
& 0xFFF);
978 switch(ddm_table
.module_type
)
981 len
+= sprintf(buf
+len
, "Downloaded DDM ");
984 len
+= sprintf(buf
+len
, "Embedded DDM ");
987 len
+= sprintf(buf
+len
, " ");
990 len
+= sprintf(buf
+len
, "%-0#7x", ddm_table
.i2o_vendor_id
);
991 len
+= sprintf(buf
+len
, "%-0#7x", ddm_table
.module_id
);
992 len
+= sprintf(buf
+len
, "%-25s", chtostr(ddm_table
.module_name
, 24));
993 len
+= sprintf(buf
+len
, "%-6s", chtostr(ddm_table
.module_version
,4));
994 len
+= sprintf(buf
+len
, "%8d ", ddm_table
.data_size
);
995 len
+= sprintf(buf
+len
, "%8d", ddm_table
.code_size
);
997 len
+= sprintf(buf
+len
, "\n");
1000 spin_unlock(&i2o_proc_lock
);
1006 /* Executive group 0004h - Driver Store (scalar) */
1007 int i2o_proc_read_ds(char *buf
, char **start
, off_t offset
, int len
,
1008 int *eof
, void *data
)
1010 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
1014 spin_lock(&i2o_proc_lock
);
1018 token
= i2o_query_scalar(c
, ADAPTER_TID
, proc_context
, 0x0004, -1,
1019 &work32
, sizeof(work32
), &i2o_proc_token
);
1023 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1024 spin_unlock(&i2o_proc_lock
);
1028 len
+= sprintf(buf
+len
, "Module limit : %d\n"
1029 "Module count : %d\n"
1030 "Current space : %d kB\n"
1031 "Free space : %d kB\n",
1032 work32
[0], work32
[1], work32
[2]>>10, work32
[3]>>10);
1034 spin_unlock(&i2o_proc_lock
);
1040 /* Executive group 0005h - Driver Store Table (table) */
1041 int i2o_proc_read_dst(char *buf
, char **start
, off_t offset
, int len
,
1042 int *eof
, void *data
)
1044 typedef struct _i2o_driver_store
{
1045 u16 stored_ddm_index
;
1050 u8 module_name_version
[28];
1055 } i2o_driver_store_table
;
1057 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
1070 i2o_driver_store_table dst
[MAX_I2O_MODULES
];
1073 i2o_driver_store_table dst
;
1075 spin_lock(&i2o_proc_lock
);
1079 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
1080 c
, ADAPTER_TID
, proc_context
,
1083 &result
, sizeof(result
), &i2o_proc_token
);
1089 len
+= sprintf(buf
, "Timeout reading table.\n");
1090 spin_unlock(&i2o_proc_lock
);
1094 len
+= sprintf(buf
, "No free memory to read the table.\n");
1095 spin_unlock(&i2o_proc_lock
);
1099 len
+= sprintf(buf
, "Error reading group. "
1100 "BlockStatus %d\n",token
);
1101 spin_unlock(&i2o_proc_lock
);
1105 len
+= sprintf(buf
+len
, "# Type Vendor Id Name Vrs Date Mod_size Par_size Flags\n");
1107 for(i
=0, dst
=result
.dst
[0]; i
< result
.row_count
; dst
=result
.dst
[++i
])
1109 len
+= sprintf(buf
+len
, "%-3d", dst
.stored_ddm_index
);
1110 switch(dst
.module_type
)
1113 len
+= sprintf(buf
+len
, "Downloaded DDM ");
1116 len
+= sprintf(buf
+len
, "Embedded DDM ");
1119 len
+= sprintf(buf
+len
, " ");
1123 if(c
->i2oversion
== 0x02)
1124 len
+= sprintf(buf
+len
, "%-d", dst
.module_state
);
1127 len
+= sprintf(buf
+len
, "%-0#7x", dst
.i2o_vendor_id
);
1128 len
+= sprintf(buf
+len
, "%-0#8x", dst
.module_id
);
1129 len
+= sprintf(buf
+len
, "%-29s", chtostr(dst
.module_name_version
,28));
1130 len
+= sprintf(buf
+len
, "%-9s", chtostr(dst
.date
,8));
1131 len
+= sprintf(buf
+len
, "%8d ", dst
.module_size
);
1132 len
+= sprintf(buf
+len
, "%8d ", dst
.mpb_size
);
1133 len
+= sprintf(buf
+len
, "0x%04x", dst
.module_flags
);
1135 if(c
->i2oversion
== 0x02)
1136 len
+= sprintf(buf
+len
, "%d",
1137 dst
.notification_level
);
1139 len
+= sprintf(buf
+len
, "\n");
1142 spin_unlock(&i2o_proc_lock
);
1148 /* Generic group F000h - Params Descriptor (table) */
1149 int i2o_proc_read_groups(char *buf
, char **start
, off_t offset
, int len
,
1150 int *eof
, void *data
)
1152 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
1160 spin_lock(&i2o_proc_lock
);
1164 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
1165 c
, ADAPTER_TID
, proc_context
,
1168 &work16
, sizeof(work16
), &i2o_proc_token
);
1174 len
+= sprintf(buf
, "Timeout reading table.\n");
1175 spin_unlock(&i2o_proc_lock
);
1179 len
+= sprintf(buf
, "No free memory to read the table.\n");
1180 spin_unlock(&i2o_proc_lock
);
1184 len
+= sprintf(buf
, "Error reading table. BlockStatus %d\n",
1186 spin_unlock(&i2o_proc_lock
);
1193 len
+= sprintf(buf
+len
, "\nPARAMS DESCRIPTOR TABLE:\n\n");
1194 len
+= sprintf(buf
+len
, "# Group FieldCount RowCount Type Add Del Clear\n");
1198 for(i
=0; i
< rows
; i
++, group
+=16)
1200 len
+= sprintf(buf
+len
, "%-3d", i
);
1202 len
+= sprintf(buf
+len
, "%-0#6x ", group
[0]);
1203 len
+= sprintf(buf
+len
, "%10d ", group
[1]);
1204 len
+= sprintf(buf
+len
, "%8d ", group
[2]);
1207 len
+= sprintf(buf
+len
, "Table ");
1209 len
+= sprintf(buf
+len
, "Scalar ");
1211 len
+= sprintf(buf
+len
, "x ");
1213 len
+= sprintf(buf
+len
, " ");
1215 len
+= sprintf(buf
+len
, "x ");
1217 len
+= sprintf(buf
+len
, " ");
1219 len
+= sprintf(buf
+len
, "x ");
1221 len
+= sprintf(buf
+len
, " ");
1223 len
+= sprintf(buf
+len
, "\n");
1227 len
+= sprintf(buf
+len
, "There is more...\n");
1229 spin_unlock(&i2o_proc_lock
);
1235 /* Generic group F005h - Private message extensions (table) */
1236 int i2o_proc_read_priv_msgs(char *buf
, char **start
, off_t offset
, int len
,
1237 int *eof
, void *data
)
1239 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
1247 spin_lock(&i2o_proc_lock
);
1251 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
1252 c
, ADAPTER_TID
, proc_context
,
1255 &work16
, sizeof(work16
), &i2o_proc_token
);
1261 len
+= sprintf(buf
, "Timeout reading table.\n");
1262 spin_unlock(&i2o_proc_lock
);
1266 len
+= sprintf(buf
, "No free memory to read the table.\n");
1267 spin_unlock(&i2o_proc_lock
);
1271 len
+= sprintf(buf
, "Error reading field. BlockStatus %d\n",
1273 spin_unlock(&i2o_proc_lock
);
1280 len
+= sprintf(buf
+len
, "Instance# OrgId FunctionCode\n");
1283 for(i
=0; i
< rows
; i
++, field
+=16)
1285 len
+= sprintf(buf
+len
, "%0#9x ", field
[0]);
1286 len
+= sprintf(buf
+len
, "%0#6x ", work16
[1]);
1287 len
+= sprintf(buf
+len
, "%0#6x", work16
[2]);
1289 len
+= sprintf(buf
+len
, "\n");
1293 len
+= sprintf(buf
+len
, "There is more...\n");
1295 spin_unlock(&i2o_proc_lock
);
1301 int i2o_proc_read_dev(char *buf
, char **start
, off_t offset
, int len
,
1302 int *eof
, void *data
)
1304 struct i2o_device
*d
= (struct i2o_device
*)data
;
1305 static u32 work32
[128]; // allow for "stuff" + up to 256 byte (max) serial number
1306 // == (allow) 512d bytes (max)
1307 static u16
*work16
= (u16
*)work32
;
1310 spin_lock(&i2o_proc_lock
);
1314 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1315 0xF100, // ParamGroup F100h (Device Identity)
1323 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1324 spin_unlock(&i2o_proc_lock
);
1328 len
+= sprintf(buf
, "Device Class : %s\n", i2o_get_class_name(work16
[0]));
1329 len
+= sprintf(buf
+len
, "Owner TID : %0#5x\n", work16
[2]);
1330 len
+= sprintf(buf
+len
, "Parent TID : %0#5x\n", work16
[3]);
1331 len
+= sprintf(buf
+len
, "Vendor info : %s\n", chtostr((u8
*)(work32
+2), 16));
1332 len
+= sprintf(buf
+len
, "Product info : %s\n", chtostr((u8
*)(work32
+6), 16));
1333 len
+= sprintf(buf
+len
, "Description : %s\n", chtostr((u8
*)(work32
+10), 16));
1334 len
+= sprintf(buf
+len
, "Product rev. : %s\n", chtostr((u8
*)(work32
+14), 8));
1336 len
+= sprintf(buf
+len
, "Serial number : ");
1337 len
= print_serial_number(buf
, len
,
1339 /* allow for SNLen plus
1340 * possible trailing '\0'
1342 sizeof(work32
)-(16*sizeof(u32
))-2
1344 len
+= sprintf(buf
+len
, "\n");
1346 spin_unlock(&i2o_proc_lock
);
1352 int i2o_proc_read_dev_name(char *buf
, char **start
, off_t offset
, int len
,
1353 int *eof
, void *data
)
1355 struct i2o_device
*d
= (struct i2o_device
*)data
;
1357 if ( d
->dev_name
[0] == '\0' )
1360 len
= sprintf(buf
, "%s\n", d
->dev_name
);
1367 int i2o_proc_read_ddm(char *buf
, char **start
, off_t offset
, int len
,
1368 int *eof
, void *data
)
1370 struct i2o_device
*d
= (struct i2o_device
*)data
;
1371 static u32 work32
[128];
1372 static u16
*work16
= (u16
*)work32
;
1375 spin_lock(&i2o_proc_lock
);
1379 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1380 0xF101, // ParamGroup F101h (DDM Identity)
1388 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1389 spin_unlock(&i2o_proc_lock
);
1393 len
+= sprintf(buf
, "Registering DDM TID : 0x%03x\n", work16
[0]&0xFFF);
1394 len
+= sprintf(buf
+len
, "Module name : %s\n", chtostr((u8
*)(work16
+1), 24));
1395 len
+= sprintf(buf
+len
, "Module revision : %s\n", chtostr((u8
*)(work16
+13), 8));
1397 len
+= sprintf(buf
+len
, "Serial number : ");
1398 len
= print_serial_number(buf
, len
,
1400 /* allow for SNLen plus
1401 * possible trailing '\0'
1403 sizeof(work32
)-(17*sizeof(u16
))-2
1405 len
+= sprintf(buf
+len
, "\n");
1407 spin_unlock(&i2o_proc_lock
);
1412 int i2o_proc_read_uinfo(char *buf
, char **start
, off_t offset
, int len
,
1413 int *eof
, void *data
)
1415 struct i2o_device
*d
= (struct i2o_device
*)data
;
1416 static u32 work32
[256];
1419 spin_lock(&i2o_proc_lock
);
1423 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1424 0xF102, // ParamGroup F102h (User Information)
1432 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1433 spin_unlock(&i2o_proc_lock
);
1437 len
+= sprintf(buf
, "Device name : %s\n", chtostr((u8
*)work32
, 64));
1438 len
+= sprintf(buf
+len
, "Service name : %s\n", chtostr((u8
*)(work32
+16), 64));
1439 len
+= sprintf(buf
+len
, "Physical name : %s\n", chtostr((u8
*)(work32
+32), 64));
1440 len
+= sprintf(buf
+len
, "Instance number : %s\n", chtostr((u8
*)(work32
+48), 4));
1442 spin_unlock(&i2o_proc_lock
);
1448 int i2o_proc_read_sgl_limits(char *buf
, char **start
, off_t offset
, int len
,
1449 int *eof
, void *data
)
1451 struct i2o_device
*d
= (struct i2o_device
*)data
;
1452 static u32 work32
[12];
1453 static u16
*work16
= (u16
*)work32
;
1454 static u8
*work8
= (u8
*)work32
;
1457 spin_lock(&i2o_proc_lock
);
1461 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1462 0xF103, // ParamGroup F103h (SGL Operating Limits)
1470 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1471 spin_unlock(&i2o_proc_lock
);
1475 len
+= sprintf(buf
, "SGL chain size : %d\n", work32
[0]);
1476 len
+= sprintf(buf
+len
, "Max SGL chain size : %d\n", work32
[1]);
1477 len
+= sprintf(buf
+len
, "SGL chain size target : %d\n", work32
[2]);
1478 len
+= sprintf(buf
+len
, "SGL frag count : %d\n", work16
[6]);
1479 len
+= sprintf(buf
+len
, "Max SGL frag count : %d\n", work16
[7]);
1480 len
+= sprintf(buf
+len
, "SGL frag count target : %d\n", work16
[8]);
1482 if (d
->i2oversion
== 0x02)
1484 len
+= sprintf(buf
+len
, "SGL data alignment : %d\n", work16
[8]);
1485 len
+= sprintf(buf
+len
, "SGL addr limit : %d\n", work8
[20]);
1486 len
+= sprintf(buf
+len
, "SGL addr sizes supported : ");
1487 if (work8
[21] & 0x01)
1488 len
+= sprintf(buf
+len
, "32 bit ");
1489 if (work8
[21] & 0x02)
1490 len
+= sprintf(buf
+len
, "64 bit ");
1491 if (work8
[21] & 0x04)
1492 len
+= sprintf(buf
+len
, "96 bit ");
1493 if (work8
[21] & 0x08)
1494 len
+= sprintf(buf
+len
, "128 bit ");
1495 len
+= sprintf(buf
+len
, "\n");
1498 spin_unlock(&i2o_proc_lock
);
1504 static int print_serial_number(char *buff
, int pos
, u8
*serialno
, int max_len
)
1508 /* 19990419 -sralston
1509 * The I2O v1.5 (and v2.0 so far) "official specification"
1510 * got serial numbers WRONG!
1511 * Apparently, and despite what Section 3.4.4 says and
1512 * Figure 3-35 shows (pg 3-39 in the pdf doc),
1513 * the convention / consensus seems to be:
1514 * + First byte is SNFormat
1515 * + Second byte is SNLen (but only if SNFormat==7 (?))
1516 * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
1520 case I2O_SNFORMAT_BINARY
: /* Binary */
1521 pos
+= sprintf(buff
+pos
, "0x");
1522 for(i
= 0; i
< serialno
[1]; i
++)
1524 pos
+= sprintf(buff
+pos
, "%02X", serialno
[2+i
]);
1528 case I2O_SNFORMAT_ASCII
: /* ASCII */
1529 if ( serialno
[1] < ' ' ) /* printable or SNLen? */
1532 max_len
= (max_len
< serialno
[1]) ? max_len
: serialno
[1];
1533 serialno
[1+max_len
] = '\0';
1536 pos
+= sprintf(buff
+pos
, "%s", &serialno
[2]);
1540 /* print chars for specified length */
1541 for(i
= 0; i
< serialno
[1]; i
++)
1543 pos
+= sprintf(buff
+pos
, "%c", serialno
[2+i
]);
1548 case I2O_SNFORMAT_UNICODE
: /* UNICODE */
1549 pos
+= sprintf(buff
+pos
, "UNICODE Format. Can't Display\n");
1552 case I2O_SNFORMAT_LAN48_MAC
: /* LAN-48 MAC Address */
1553 pos
+= sprintf(buff
+pos
,
1554 "LAN-48 MAC address @ %02X:%02X:%02X:%02X:%02X:%02X",
1555 serialno
[2], serialno
[3],
1556 serialno
[4], serialno
[5],
1557 serialno
[6], serialno
[7]);
1560 case I2O_SNFORMAT_WAN
: /* WAN MAC Address */
1561 /* FIXME: Figure out what a WAN access address looks like?? */
1562 pos
+= sprintf(buff
+pos
, "WAN Access Address");
1565 /* plus new in v2.0 */
1566 case I2O_SNFORMAT_LAN64_MAC
: /* LAN-64 MAC Address */
1567 /* FIXME: Figure out what a LAN-64 address really looks like?? */
1568 pos
+= sprintf(buff
+pos
,
1569 "LAN-64 MAC address @ [?:%02X:%02X:?] %02X:%02X:%02X:%02X:%02X:%02X",
1570 serialno
[8], serialno
[9],
1571 serialno
[2], serialno
[3],
1572 serialno
[4], serialno
[5],
1573 serialno
[6], serialno
[7]);
1577 case I2O_SNFORMAT_DDM
: /* I2O DDM */
1578 pos
+= sprintf(buff
+pos
,
1579 "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
1580 *(u16
*)&serialno
[2],
1581 *(u16
*)&serialno
[4],
1582 *(u16
*)&serialno
[6]);
1585 case I2O_SNFORMAT_IEEE_REG64
: /* IEEE Registered (64-bit) */
1586 case I2O_SNFORMAT_IEEE_REG128
: /* IEEE Registered (128-bit) */
1587 /* FIXME: Figure if this is even close?? */
1588 pos
+= sprintf(buff
+pos
,
1589 "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n",
1590 *(u32
*)&serialno
[2],
1591 *(u32
*)&serialno
[6],
1592 *(u32
*)&serialno
[10],
1593 *(u32
*)&serialno
[14]);
1597 case I2O_SNFORMAT_UNKNOWN
: /* Unknown 0 */
1598 case I2O_SNFORMAT_UNKNOWN2
: /* Unknown 0xff */
1600 pos
+= sprintf(buff
+pos
, "Unknown data format (0x%02x)",
1608 const char * i2o_get_connector_type(int conn
)
1611 static char *i2o_connector_type
[] = {
1682 return i2o_connector_type
[idx
];
1686 const char * i2o_get_connection_type(int conn
)
1689 static char *i2o_connection_type
[] = {
1723 case I2O_LAN_UNKNOWN
:
1729 case I2O_LAN_10BASE5
:
1735 case I2O_LAN_10BASE2
:
1738 case I2O_LAN_10BROAD36
:
1741 case I2O_LAN_10BASE_T
:
1744 case I2O_LAN_10BASE_FP
:
1747 case I2O_LAN_10BASE_FB
:
1750 case I2O_LAN_10BASE_FL
:
1753 case I2O_LAN_100BASE_TX
:
1756 case I2O_LAN_100BASE_FX
:
1759 case I2O_LAN_100BASE_T4
:
1762 case I2O_LAN_1000BASE_SX
:
1765 case I2O_LAN_1000BASE_LX
:
1768 case I2O_LAN_1000BASE_CX
:
1771 case I2O_LAN_1000BASE_T
:
1774 case I2O_LAN_100VG_ETHERNET
:
1777 case I2O_LAN_100VG_TR
:
1783 case I2O_LAN_16MBIT
:
1786 case I2O_LAN_125MBAUD
:
1789 case I2O_LAN_POINT_POINT
:
1792 case I2O_LAN_ARB_LOOP
:
1795 case I2O_LAN_PUBLIC_LOOP
:
1798 case I2O_LAN_FABRIC
:
1801 case I2O_LAN_EMULATION
:
1807 case I2O_LAN_DEFAULT
:
1812 return i2o_connection_type
[idx
];
1816 /* LAN group 0000h - Device info (scalar) */
1817 int i2o_proc_read_lan_dev_info(char *buf
, char **start
, off_t offset
, int len
,
1818 int *eof
, void *data
)
1820 struct i2o_device
*d
= (struct i2o_device
*)data
;
1821 static u32 work32
[56];
1822 static u8
*work8
= (u8
*)work32
;
1823 static u16
*work16
= (u16
*)work32
;
1824 static u64
*work64
= (u64
*)work32
;
1827 spin_lock(&i2o_proc_lock
);
1831 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1832 0x0000, -1, &work32
, 56*4, &i2o_proc_token
);
1835 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1836 spin_unlock(&i2o_proc_lock
);
1840 len
+= sprintf(buf
, "LAN Type : ");
1844 len
+= sprintf(buf
+len
, "Ethernet, ");
1847 len
+= sprintf(buf
+len
, "100Base VG, ");
1850 len
+= sprintf(buf
+len
, "Token Ring, ");
1853 len
+= sprintf(buf
+len
, "FDDI, ");
1856 len
+= sprintf(buf
+len
, "Fibre Channel, ");
1859 len
+= sprintf(buf
+len
, "Unknown type (0x%04x), ", work16
[0]);
1863 if (work16
[1]&0x00000001)
1864 len
+= sprintf(buf
+len
, "emulated LAN, ");
1866 len
+= sprintf(buf
+len
, "physical LAN port, ");
1868 if (work16
[1]&0x00000002)
1869 len
+= sprintf(buf
+len
, "full duplex\n");
1871 len
+= sprintf(buf
+len
, "simplex\n");
1873 len
+= sprintf(buf
+len
, "Address format : ");
1876 len
+= sprintf(buf
+len
, "IEEE 48bit\n");
1879 len
+= sprintf(buf
+len
, "FC IEEE\n");
1882 len
+= sprintf(buf
+len
, "Unknown (0x%02x)\n", work8
[4]);
1886 len
+= sprintf(buf
+len
, "State : ");
1890 len
+= sprintf(buf
+len
, "Unknown\n");
1893 len
+= sprintf(buf
+len
, "Unclaimed\n");
1896 len
+= sprintf(buf
+len
, "Operational\n");
1899 len
+= sprintf(buf
+len
, "Suspended\n");
1902 len
+= sprintf(buf
+len
, "Resetting\n");
1905 len
+= sprintf(buf
+len
, "ERROR: ");
1906 if(work16
[3]&0x0001)
1907 len
+= sprintf(buf
+len
, "TxCU inoperative ");
1908 if(work16
[3]&0x0002)
1909 len
+= sprintf(buf
+len
, "RxCU inoperative ");
1910 if(work16
[3]&0x0004)
1911 len
+= sprintf(buf
+len
, "Local mem alloc ");
1912 len
+= sprintf(buf
+len
, "\n");
1915 len
+= sprintf(buf
+len
, "Operational no Rx\n");
1918 len
+= sprintf(buf
+len
, "Suspended no Rx\n");
1921 len
+= sprintf(buf
+len
, "Unspecified\n");
1925 len
+= sprintf(buf
+len
, "Min packet size : %d\n", work32
[2]);
1926 len
+= sprintf(buf
+len
, "Max packet size : %d\n", work32
[3]);
1927 len
+= sprintf(buf
+len
, "HW address : "
1928 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1929 work8
[16],work8
[17],work8
[18],work8
[19],
1930 work8
[20],work8
[21],work8
[22],work8
[23]);
1932 len
+= sprintf(buf
+len
, "Max Tx wire speed : %d bps\n", work64
[3]);
1933 len
+= sprintf(buf
+len
, "Max Rx wire speed : %d bps\n", work64
[4]);
1935 len
+= sprintf(buf
+len
, "Min SDU packet size : 0x%08x\n", work32
[10]);
1936 len
+= sprintf(buf
+len
, "Max SDU packet size : 0x%08x\n", work32
[11]);
1938 spin_unlock(&i2o_proc_lock
);
1942 /* LAN group 0001h - MAC address table (scalar) */
1943 int i2o_proc_read_lan_mac_addr(char *buf
, char **start
, off_t offset
, int len
,
1944 int *eof
, void *data
)
1946 struct i2o_device
*d
= (struct i2o_device
*)data
;
1947 static u32 work32
[48];
1948 static u8
*work8
= (u8
*)work32
;
1951 spin_lock(&i2o_proc_lock
);
1954 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1955 0x0001, -1, &work32
, 48*4, &i2o_proc_token
);
1958 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1959 spin_unlock(&i2o_proc_lock
);
1963 len
+= sprintf(buf
, "Active address : "
1964 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1965 work8
[0],work8
[1],work8
[2],work8
[3],
1966 work8
[4],work8
[5],work8
[6],work8
[7]);
1967 len
+= sprintf(buf
+len
, "Current address : "
1968 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1969 work8
[8],work8
[9],work8
[10],work8
[11],
1970 work8
[12],work8
[13],work8
[14],work8
[15]);
1971 len
+= sprintf(buf
+len
, "Functional address mask : "
1972 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1973 work8
[16],work8
[17],work8
[18],work8
[19],
1974 work8
[20],work8
[21],work8
[22],work8
[23]);
1976 len
+= sprintf(buf
+len
, "HW/DDM capabilities : 0x%08x\n", work32
[7]);
1977 len
+= sprintf(buf
+len
, " Unicast packets %ssupported\n",
1978 (work32
[7]&0x00000001)?"":"not ");
1979 len
+= sprintf(buf
+len
, " Promiscuous mode %ssupported\n",
1980 (work32
[7]&0x00000002)?"":"not");
1981 len
+= sprintf(buf
+len
, " Promiscuous multicast mode %ssupported\n",
1982 (work32
[7]&0x00000004)?"":"not ");
1983 len
+= sprintf(buf
+len
," Broadcast reception disabling %ssupported\n",
1984 (work32
[7]&0x00000100)?"":"not ");
1985 len
+= sprintf(buf
+len
," Multicast reception disabling %ssupported\n",
1986 (work32
[7]&0x00000200)?"":"not ");
1987 len
+= sprintf(buf
+len
," Functional address disabling %ssupported\n",
1988 (work32
[7]&0x00000400)?"":"not ");
1989 len
+= sprintf(buf
+len
, " MAC reporting %ssupported\n",
1990 (work32
[7]&0x00000800)?"":"not ");
1992 len
+= sprintf(buf
+len
, "Filter mask : 0x%08x\n", work32
[6]);
1993 len
+= sprintf(buf
+len
, " Unicast packets %s\n",
1994 (work32
[6]&0x00000001)?"rejected":"enabled");
1995 len
+= sprintf(buf
+len
, " Promiscuous mode %s\n",
1996 (work32
[6]&0x00000002)?"enabled":"disabled");
1997 len
+= sprintf(buf
+len
, " Promiscuous multicast mode %s\n",
1998 (work32
[6]&0x00000004)?"enabled":"disabled");
1999 len
+= sprintf(buf
+len
, " Broadcast packets %s\n",
2000 (work32
[6]&0x00000100)?"rejected":"enabled");
2001 len
+= sprintf(buf
+len
, " Multicast packets %s\n",
2002 (work32
[6]&0x00000200)?"rejected":"enabled");
2003 len
+= sprintf(buf
+len
, " Functional address %s\n",
2004 (work32
[6]&0x00000400)?"ignored":"enabled");
2006 if (work32
[7]&0x00000800)
2008 len
+= sprintf(buf
+len
, " MAC reporting mode : ");
2009 if (work32
[6]&0x00000800)
2010 len
+= sprintf(buf
+len
, "Pass only priority MAC packets to user\n");
2011 else if (work32
[6]&0x00001000)
2012 len
+= sprintf(buf
+len
, "Pass all MAC packets to user\n");
2013 else if (work32
[6]&0x00001800)
2014 len
+= sprintf(buf
+len
, "Pass all MAC packets (promiscuous) to user\n");
2016 len
+= sprintf(buf
+len
, "Do not pass MAC packets to user\n");
2018 len
+= sprintf(buf
+len
, "Number of multicast addresses : %d\n", work32
[8]);
2019 len
+= sprintf(buf
+len
, "Perfect filtering for max %d multicast addresses\n",
2021 len
+= sprintf(buf
+len
, "Imperfect filtering for max %d multicast addresses\n",
2024 spin_unlock(&i2o_proc_lock
);
2029 /* LAN group 0002h - Multicast MAC address table (table) */
2030 int i2o_proc_read_lan_mcast_addr(char *buf
, char **start
, off_t offset
,
2031 int len
, int *eof
, void *data
)
2033 struct i2o_device
*d
= (struct i2o_device
*)data
;
2034 static u32 field32
[64];
2035 static u8
*field8
= (u8
*)field32
;
2036 static u16
*field16
= (u16
*)field32
;
2040 spin_lock(&i2o_proc_lock
);
2043 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
2044 d
->controller
, d
->id
, proc_context
, 0x0002, -1,
2045 NULL
, 0, &field32
, sizeof(field32
),
2051 len
+= sprintf(buf
, "Timeout reading table.\n");
2052 spin_unlock(&i2o_proc_lock
);
2056 len
+= sprintf(buf
, "No free memory to read the table.\n");
2057 spin_unlock(&i2o_proc_lock
);
2061 len
+= sprintf(buf
, "Error reading field. BlockStatus %d\n",
2063 spin_unlock(&i2o_proc_lock
);
2067 len
+= sprintf(buf
, "RowCount=%d, MoreFlag=%d\n",
2068 field16
[0], field16
[1]);
2070 field8
=(u8
*)&field16
[2];
2072 for(i
=0; i
<field16
[0]; i
++, field8
+=8)
2074 len
+= sprintf(buf
+len
, "MC MAC address[%d]: "
2075 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2077 field8
[0], field8
[1], field8
[2],
2078 field8
[3], field8
[4], field8
[5],
2079 field8
[6], field8
[7]);
2082 spin_unlock(&i2o_proc_lock
);
2086 /* LAN group 0003h - Batch Control (scalar) */
2087 int i2o_proc_read_lan_batch_control(char *buf
, char **start
, off_t offset
,
2088 int len
, int *eof
, void *data
)
2090 struct i2o_device
*d
= (struct i2o_device
*)data
;
2091 static u32 work32
[9];
2094 spin_lock(&i2o_proc_lock
);
2097 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2098 0x0003, -1, &work32
, 9*4, &i2o_proc_token
);
2101 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2102 spin_unlock(&i2o_proc_lock
);
2106 len
+= sprintf(buf
, "Batch mode ");
2107 if (work32
[0]&0x00000001)
2108 len
+= sprintf(buf
+len
, "disabled");
2110 len
+= sprintf(buf
+len
, "enabled");
2111 if (work32
[0]&0x00000002)
2112 len
+= sprintf(buf
+len
, " (current setting)");
2113 if (work32
[0]&0x00000004)
2114 len
+= sprintf(buf
+len
, ", forced");
2116 len
+= sprintf(buf
+len
, ", toggle");
2117 len
+= sprintf(buf
+len
, "\n");
2119 if(d
->i2oversion
== 0x00) { /* Reserved in 1.53 and 2.0 */
2120 len
+= sprintf(buf
+len
, "Rising load delay : %d ms\n",
2122 len
+= sprintf(buf
+len
, "Rising load threshold : %d ms\n",
2124 len
+= sprintf(buf
+len
, "Falling load delay : %d ms\n",
2126 len
+= sprintf(buf
+len
, "Falling load threshold : %d ms\n",
2130 len
+= sprintf(buf
+len
, "Max Rx batch count : %d\n", work32
[5]);
2131 len
+= sprintf(buf
+len
, "Max Rx batch delay : %d\n", work32
[6]);
2133 if(d
->i2oversion
== 0x00) {
2134 len
+= sprintf(buf
+len
,
2135 "Transmission completion reporting delay : %d ms\n",
2138 len
+= sprintf(buf
+len
, "Max Tx batch delay : %d\n", work32
[7]);
2139 len
+= sprintf(buf
+len
, "Max Tx batch count : %d\n", work32
[8]);
2142 spin_unlock(&i2o_proc_lock
);
2146 /* LAN group 0004h - LAN Operation (scalar) */
2147 int i2o_proc_read_lan_operation(char *buf
, char **start
, off_t offset
, int len
,
2148 int *eof
, void *data
)
2150 struct i2o_device
*d
= (struct i2o_device
*)data
;
2151 static u32 work32
[5];
2154 spin_lock(&i2o_proc_lock
);
2157 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2158 0x0004, -1, &work32
, 20, &i2o_proc_token
);
2161 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2162 spin_unlock(&i2o_proc_lock
);
2166 len
+= sprintf(buf
, "Packet prepadding (32b words) : %d\n", work32
[0]);
2167 len
+= sprintf(buf
+len
, "Transmission error reporting : %s\n",
2168 (work32
[1]&1)?"on":"off");
2169 len
+= sprintf(buf
+len
, "Bad packet handling : %s\n",
2170 (work32
[1]&0x2)?"by host":"by DDM");
2171 len
+= sprintf(buf
+len
, "Packet orphan limit : %d\n", work32
[2]);
2173 len
+= sprintf(buf
+len
, "Tx modes :\n");
2174 if (work32
[3]&0x00000004)
2175 len
+= sprintf(buf
+len
, " HW CRC supressed\n");
2177 len
+= sprintf(buf
+len
, " HW CRC\n");
2178 if (work32
[3]&0x00000100)
2179 len
+= sprintf(buf
+len
, " HW IPv4 checksumming\n");
2180 if (work32
[3]&0x00000200)
2181 len
+= sprintf(buf
+len
, " HW TCP checksumming\n");
2182 if (work32
[3]&0x00000400)
2183 len
+= sprintf(buf
+len
, " HW UDP checksumming\n");
2184 if (work32
[3]&0x00000800)
2185 len
+= sprintf(buf
+len
, " HW RSVP checksumming\n");
2186 if (work32
[3]&0x00001000)
2187 len
+= sprintf(buf
+len
, " HW ICMP checksumming\n");
2188 if (work32
[3]&0x00002000)
2189 len
+= sprintf(buf
+len
, " Loopback packet not delivered\n");
2191 len
+= sprintf(buf
+len
, "Rx modes :\n");
2192 if (work32
[4]&0x00000004)
2193 len
+= sprintf(buf
+len
, " FCS in payload\n");
2194 if (work32
[4]&0x00000100)
2195 len
+= sprintf(buf
+len
, " HW IPv4 checksum validation\n");
2196 if (work32
[4]&0x00000200)
2197 len
+= sprintf(buf
+len
, " HW TCP checksum validation\n");
2198 if (work32
[4]&0x00000400)
2199 len
+= sprintf(buf
+len
, " HW UDP checksum validation\n");
2200 if (work32
[4]&0x00000800)
2201 len
+= sprintf(buf
+len
, " HW RSVP checksum validation\n");
2202 if (work32
[4]&0x00001000)
2203 len
+= sprintf(buf
+len
, " HW ICMP checksum validation\n");
2205 spin_unlock(&i2o_proc_lock
);
2209 /* LAN group 0005h - Media operation (scalar) */
2210 int i2o_proc_read_lan_media_operation(char *buf
, char **start
, off_t offset
,
2211 int len
, int *eof
, void *data
)
2213 struct i2o_device
*d
= (struct i2o_device
*)data
;
2214 static u32 work32
[9];
2215 static u8
*work8
= (u8
*)work32
;
2216 static u64
*work64
= (u64
*)work32
;
2219 spin_lock(&i2o_proc_lock
);
2222 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2223 0x0005, -1, &work32
, 36, &i2o_proc_token
);
2226 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2227 spin_unlock(&i2o_proc_lock
);
2231 len
+= sprintf(buf
, "Connector type : %s\n",
2232 i2o_get_connector_type(work32
[0]));
2233 len
+= sprintf(buf
+len
, "Connection type : %s\n",
2234 i2o_get_connection_type(work32
[1]));
2236 len
+= sprintf(buf
+len
, "Current Tx wire speed : %d bps\n", work64
[1]);
2237 len
+= sprintf(buf
+len
, "Current Rx wire speed : %d bps\n", work64
[2]);
2239 len
+= sprintf(buf
+len
, "Duplex mode : %s duplex\n",
2240 (work8
[24]&1)?"Full":"Half");
2241 len
+= sprintf(buf
+len
, "Link status : ");
2242 if(work8
[25] == 0x00)
2243 len
+= sprintf(buf
+len
, "Unknown\n");
2244 else if(work8
[25] == 0x01)
2245 len
+= sprintf(buf
+len
, "Normal\n");
2246 else if(work8
[25] == 0x02)
2247 len
+= sprintf(buf
+len
, "Failure\n");
2248 else if(work8
[25] == 0x03)
2249 len
+= sprintf(buf
+len
, "Reset\n");
2251 len
+= sprintf(buf
+len
, "Unspecified\n");
2253 if (d
->i2oversion
== 0x00) { /* Reserved in 1.53 and 2.0 */
2254 len
+= sprintf(buf
+len
, "Bad packets handled by : %s\n",
2255 (work8
[26] == 0xFF)?"host":"DDM");
2257 if (d
->i2oversion
!= 0x00) {
2258 len
+= sprintf(buf
+len
, "Duplex mode target : ");
2259 switch (work8
[27]) {
2261 len
+= sprintf(buf
+len
, "Half duplex\n");
2264 len
+= sprintf(buf
+len
, "Full duplex\n");
2267 len
+= sprintf(buf
+len
, "\n");
2271 len
+= sprintf(buf
+len
, "Connector type target : %s\n",
2272 i2o_get_connector_type(work32
[7]));
2273 len
+= sprintf(buf
+len
, "Connection type target : %s\n",
2274 i2o_get_connection_type(work32
[8]));
2277 spin_unlock(&i2o_proc_lock
);
2281 /* LAN group 0006h - Alternate address (table) */
2282 int i2o_proc_read_lan_alt_addr(char *buf
, char **start
, off_t offset
, int len
,
2283 int *eof
, void *data
)
2285 struct i2o_device
*d
= (struct i2o_device
*)data
;
2286 static u32 field32
[64];
2287 static u8
*field8
= (u8
*)field32
;
2288 static u16
*field16
= (u16
*)field32
;
2292 spin_lock(&i2o_proc_lock
);
2295 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
2296 d
->controller
, d
->id
, proc_context
, 0x0006, -1,
2297 NULL
, 0, &field32
, sizeof(field32
),
2303 len
+= sprintf(buf
, "Timeout reading table.\n");
2304 spin_unlock(&i2o_proc_lock
);
2308 len
+= sprintf(buf
, "No free memory to read the table.\n");
2309 spin_unlock(&i2o_proc_lock
);
2313 len
+= sprintf(buf
, "Error reading field. BlockStatus %d\n",
2315 spin_unlock(&i2o_proc_lock
);
2319 len
+= sprintf(buf
,"RowCount=%d, MoreFlag=%d\n", field16
[0],
2322 field8
=(u8
*)&field16
[2];
2324 for(i
=0; i
<field16
[0]; i
++, field8
+=8)
2326 len
+= sprintf(buf
+len
, "Alternate address[%d]: "
2327 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2329 field8
[0], field8
[1], field8
[2],
2330 field8
[3], field8
[4], field8
[5],
2331 field8
[6], field8
[7]);
2334 spin_unlock(&i2o_proc_lock
);
2339 /* LAN group 0007h - Transmit info (scalar) */
2340 int i2o_proc_read_lan_tx_info(char *buf
, char **start
, off_t offset
, int len
,
2341 int *eof
, void *data
)
2343 struct i2o_device
*d
= (struct i2o_device
*)data
;
2344 static u32 work32
[8];
2347 spin_lock(&i2o_proc_lock
);
2350 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2351 0x0007, -1, &work32
, 8*4, &i2o_proc_token
);
2354 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2355 spin_unlock(&i2o_proc_lock
);
2359 len
+= sprintf(buf
, "Max SG Elements per packet : %d\n", work32
[0]);
2360 len
+= sprintf(buf
+len
, "Max SG Elements per chain : %d\n", work32
[1]);
2361 len
+= sprintf(buf
+len
, "Max outstanding packets : %d\n", work32
[2]);
2362 len
+= sprintf(buf
+len
, "Max packets per request : %d\n", work32
[3]);
2364 len
+= sprintf(buf
+len
, "Tx modes :\n");
2365 if(work32
[4]&0x00000002)
2366 len
+= sprintf(buf
+len
, " No DA in SGL\n");
2367 if(work32
[4]&0x00000004)
2368 len
+= sprintf(buf
+len
, " CRC suppression\n");
2369 if(work32
[4]&0x00000008)
2370 len
+= sprintf(buf
+len
, " Loop suppression\n");
2371 if(work32
[4]&0x00000010)
2372 len
+= sprintf(buf
+len
, " MAC insertion\n");
2373 if(work32
[4]&0x00000020)
2374 len
+= sprintf(buf
+len
, " RIF insertion\n");
2375 if(work32
[4]&0x00000100)
2376 len
+= sprintf(buf
+len
, " IPv4 checksum\n");
2377 if(work32
[4]&0x00000200)
2378 len
+= sprintf(buf
+len
, " TCP checksum\n");
2379 if(work32
[4]&0x00000400)
2380 len
+= sprintf(buf
+len
, " UDP checksum\n");
2381 if(work32
[4]&0x00000800)
2382 len
+= sprintf(buf
+len
, " RSVP checksum\n");
2383 if(work32
[4]&0x00001000)
2384 len
+= sprintf(buf
+len
, " ICMP checksum\n");
2385 if (d
->i2oversion
== 0x00) {
2386 if(work32
[4]&0x00008000)
2387 len
+= sprintf(buf
+len
, " Loopback enabled\n");
2388 if(work32
[4]&0x00010000)
2389 len
+= sprintf(buf
+len
, " Loopback suppression enabled\n");
2391 if(work32
[4]&0x00010000)
2392 len
+= sprintf(buf
+len
, " Loopback enabled\n");
2393 if(work32
[4]&0x00020000)
2394 len
+= sprintf(buf
+len
, " Loopback suppression enabled\n");
2397 spin_unlock(&i2o_proc_lock
);
2401 /* LAN group 0008h - Receive info (scalar) */
2402 int i2o_proc_read_lan_rx_info(char *buf
, char **start
, off_t offset
, int len
,
2403 int *eof
, void *data
)
2405 struct i2o_device
*d
= (struct i2o_device
*)data
;
2406 static u32 work32
[8];
2409 spin_lock(&i2o_proc_lock
);
2412 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2413 0x0008, -1, &work32
, 8*4, &i2o_proc_token
);
2416 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2417 spin_unlock(&i2o_proc_lock
);
2421 len
+= sprintf(buf
,"Max size of chain element : %d\n", work32
[0]);
2422 len
+= sprintf(buf
+len
, "Max number of buckets : %d\n", work32
[1]);
2424 if (d
->i2oversion
> 0x00) { /* not in 1.5 */
2425 len
+= sprintf(buf
+len
, "RxModes : %d\n", work32
[2]);
2426 len
+= sprintf(buf
+len
, "RxMaxBucketsReply : %d\n", work32
[3]);
2427 len
+= sprintf(buf
+len
, "RxMaxPacketsPerBuckets : %d\n", work32
[4]);
2428 len
+= sprintf(buf
+len
, "RxMaxPostBuckets : %d\n", work32
[5]);
2431 spin_unlock(&i2o_proc_lock
);
2436 /* LAN group 0100h - LAN Historical statistics (scalar) */
2437 int i2o_proc_read_lan_hist_stats(char *buf
, char **start
, off_t offset
, int len
,
2438 int *eof
, void *data
)
2440 struct i2o_device
*d
= (struct i2o_device
*)data
;
2441 static u64 work64
[9];
2444 spin_lock(&i2o_proc_lock
);
2447 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2448 0x0100, -1, &work64
, 9*8, &i2o_proc_token
);
2451 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2452 spin_unlock(&i2o_proc_lock
);
2456 len
+= sprintf(buf
, "Tx packets : " FMT_U64_HEX
"\n",
2457 U64_VAL(&work64
[0]));
2458 len
+= sprintf(buf
+len
, "Tx bytes : " FMT_U64_HEX
"\n",
2459 U64_VAL(&work64
[1]));
2460 len
+= sprintf(buf
+len
, "Rx packets : " FMT_U64_HEX
"\n",
2461 U64_VAL(&work64
[2]));
2462 len
+= sprintf(buf
+len
, "Rx bytes : " FMT_U64_HEX
"\n",
2463 U64_VAL(&work64
[3]));
2464 len
+= sprintf(buf
+len
, "Tx errors : " FMT_U64_HEX
"\n",
2465 U64_VAL(&work64
[4]));
2466 len
+= sprintf(buf
+len
, "Rx errors : " FMT_U64_HEX
"\n",
2467 U64_VAL(&work64
[5]));
2468 len
+= sprintf(buf
+len
, "Rx dropped : " FMT_U64_HEX
"\n",
2469 U64_VAL(&work64
[6]));
2470 len
+= sprintf(buf
+len
, "Adapter resets : " FMT_U64_HEX
"\n",
2471 U64_VAL(&work64
[7]));
2472 len
+= sprintf(buf
+len
, "Adapter suspends : " FMT_U64_HEX
"\n",
2473 U64_VAL(&work64
[8]));
2475 spin_unlock(&i2o_proc_lock
);
2480 /* LAN group 0180h - Supported Optional Historical Statistics (scalar) */
2481 int i2o_proc_read_lan_supp_opt_stats(char *buf
, char **start
, off_t offset
,
2482 int len
, int *eof
, void *data
)
2484 struct i2o_device
*d
= (struct i2o_device
*)data
;
2485 static u64 work64
[4];
2488 spin_lock(&i2o_proc_lock
);
2492 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2493 0x0180, -1, &work64
, 4*8, &i2o_proc_token
);
2496 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2497 spin_unlock(&i2o_proc_lock
);
2501 if (d
->i2oversion
== 0x00)
2502 len
+= sprintf(buf
, "Supported stats : " FMT_U64_HEX
" \n",
2503 U64_VAL(&work64
[0]));
2506 len
+= sprintf(buf
, "Supported stats (0182h) : " FMT_U64_HEX
" \n",
2507 U64_VAL(&work64
[1]));
2508 len
+= sprintf(buf
, "Supported stats (0183h) : " FMT_U64_HEX
" \n",
2509 U64_VAL(&work64
[2]));
2510 len
+= sprintf(buf
, "Supported stats (0184h) : " FMT_U64_HEX
" \n",
2511 U64_VAL(&work64
[3]));
2514 spin_unlock(&i2o_proc_lock
);
2519 /* LAN group 0182h - Optional Non Media Specific Transmit Historical Statistics
2521 int i2o_proc_read_lan_opt_tx_hist_stats(char *buf
, char **start
, off_t offset
,
2522 int len
, int *eof
, void *data
)
2524 struct i2o_device
*d
= (struct i2o_device
*)data
;
2525 static u64 work64
[9];
2528 spin_lock(&i2o_proc_lock
);
2532 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2533 0x0182, -1, &work64
, 9*8, &i2o_proc_token
);
2536 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2537 spin_unlock(&i2o_proc_lock
);
2541 len
+= sprintf(buf
, "TxRetryCount : " FMT_U64_HEX
"\n",
2542 U64_VAL(&work64
[0]));
2543 len
+= sprintf(buf
+len
, "DirectedBytesTx : " FMT_U64_HEX
"\n",
2544 U64_VAL(&work64
[1]));
2545 len
+= sprintf(buf
+len
, "DirectedPacketsTx : " FMT_U64_HEX
"\n",
2546 U64_VAL(&work64
[2]));
2547 len
+= sprintf(buf
+len
, "MulticastBytesTx : " FMT_U64_HEX
"\n",
2548 U64_VAL(&work64
[3]));
2549 len
+= sprintf(buf
+len
, "MulticastPacketsTx : " FMT_U64_HEX
"\n",
2550 U64_VAL(&work64
[4]));
2551 len
+= sprintf(buf
+len
, "BroadcastBytesTx : " FMT_U64_HEX
"\n",
2552 U64_VAL(&work64
[5]));
2553 len
+= sprintf(buf
+len
, "BroadcastPacketsTx : " FMT_U64_HEX
"\n",
2554 U64_VAL(&work64
[6]));
2555 len
+= sprintf(buf
+len
, "TotalGroupAddrTxCount : " FMT_U64_HEX
"\n",
2556 U64_VAL(&work64
[7]));
2557 len
+= sprintf(buf
+len
, "TotalTxPacketsTooShort : " FMT_U64_HEX
"\n",
2558 U64_VAL(&work64
[8]));
2560 spin_unlock(&i2o_proc_lock
);
2564 /* LAN group 0183h - Optional Non Media Specific Receive Historical Statistics
2566 int i2o_proc_read_lan_opt_rx_hist_stats(char *buf
, char **start
, off_t offset
,
2567 int len
, int *eof
, void *data
)
2569 struct i2o_device
*d
= (struct i2o_device
*)data
;
2570 static u64 work64
[11];
2573 spin_lock(&i2o_proc_lock
);
2577 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2578 0x0183, -1, &work64
, 11*8, &i2o_proc_token
);
2581 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2582 spin_unlock(&i2o_proc_lock
);
2586 len
+= sprintf(buf
, "ReceiveCRCErrorCount : " FMT_U64_HEX
"\n",
2587 U64_VAL(&work64
[0]));
2588 len
+= sprintf(buf
+len
, "DirectedBytesRx : " FMT_U64_HEX
"\n",
2589 U64_VAL(&work64
[1]));
2590 len
+= sprintf(buf
+len
, "DirectedPacketsRx : " FMT_U64_HEX
"\n",
2591 U64_VAL(&work64
[2]));
2592 len
+= sprintf(buf
+len
, "MulticastBytesRx : " FMT_U64_HEX
"\n",
2593 U64_VAL(&work64
[3]));
2594 len
+= sprintf(buf
+len
, "MulticastPacketsRx : " FMT_U64_HEX
"\n",
2595 U64_VAL(&work64
[4]));
2596 len
+= sprintf(buf
+len
, "BroadcastBytesRx : " FMT_U64_HEX
"\n",
2597 U64_VAL(&work64
[5]));
2598 len
+= sprintf(buf
+len
, "BroadcastPacketsRx : " FMT_U64_HEX
"\n",
2599 U64_VAL(&work64
[6]));
2600 len
+= sprintf(buf
+len
, "TotalGroupAddrRxCount : " FMT_U64_HEX
"\n",
2601 U64_VAL(&work64
[7]));
2602 len
+= sprintf(buf
+len
, "TotalRxPacketsTooShort : " FMT_U64_HEX
"\n",
2603 U64_VAL(&work64
[8]));
2604 len
+= sprintf(buf
+len
, "TotalRxPacketsTooLong : " FMT_U64_HEX
"\n",
2605 U64_VAL(&work64
[9]));
2606 len
+= sprintf(buf
+len
, "TotalRuntPacketsReceived : " FMT_U64_HEX
"\n",
2607 U64_VAL(&work64
[10]));
2609 spin_unlock(&i2o_proc_lock
);
2613 /* LAN group 0200h - Required Ethernet Statistics (scalar) */
2614 int i2o_proc_read_lan_eth_stats(char *buf
, char **start
, off_t offset
,
2615 int len
, int *eof
, void *data
)
2617 struct i2o_device
*d
= (struct i2o_device
*)data
;
2618 static u64 work64
[8];
2622 spin_lock(&i2o_proc_lock
);
2626 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2627 0x0200, -1, &work64
, 8*8, &i2o_proc_token
);
2630 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2631 spin_unlock(&i2o_proc_lock
);
2635 len
+= sprintf(buf
, "Rx alignment errors : " FMT_U64_HEX
"\n",
2636 U64_VAL(&work64
[0]));
2637 len
+= sprintf(buf
+len
, "Tx one collisions : " FMT_U64_HEX
"\n",
2638 U64_VAL(&work64
[1]));
2639 len
+= sprintf(buf
+len
, "Tx multicollisions : " FMT_U64_HEX
"\n",
2640 U64_VAL(&work64
[2]));
2641 len
+= sprintf(buf
+len
, "Tx deferred : " FMT_U64_HEX
"\n",
2642 U64_VAL(&work64
[3]));
2643 len
+= sprintf(buf
+len
, "Tx late collisions : " FMT_U64_HEX
"\n",
2644 U64_VAL(&work64
[4]));
2645 len
+= sprintf(buf
+len
, "Tx max collisions : " FMT_U64_HEX
"\n",
2646 U64_VAL(&work64
[5]));
2647 len
+= sprintf(buf
+len
, "Tx carrier lost : " FMT_U64_HEX
"\n",
2648 U64_VAL(&work64
[6]));
2649 len
+= sprintf(buf
+len
, "Tx excessive deferrals : " FMT_U64_HEX
"\n",
2650 U64_VAL(&work64
[7]));
2652 spin_unlock(&i2o_proc_lock
);
2656 /* LAN group 0280h - Supported Ethernet Historical Statistics (scalar) */
2657 int i2o_proc_read_lan_supp_eth_stats(char *buf
, char **start
, off_t offset
,
2658 int len
, int *eof
, void *data
)
2660 struct i2o_device
*d
= (struct i2o_device
*)data
;
2661 static u64 work64
[1];
2664 spin_lock(&i2o_proc_lock
);
2668 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2669 0x0280, -1, &work64
, 8, &i2o_proc_token
);
2672 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2673 spin_unlock(&i2o_proc_lock
);
2677 len
+= sprintf(buf
, "Supported stats : " FMT_U64_HEX
"\n",
2678 U64_VAL(&work64
[0]));
2680 spin_unlock(&i2o_proc_lock
);
2684 /* LAN group 0281h - Optional Ethernet Historical Statistics (scalar) */
2685 int i2o_proc_read_lan_opt_eth_stats(char *buf
, char **start
, off_t offset
,
2686 int len
, int *eof
, void *data
)
2688 struct i2o_device
*d
= (struct i2o_device
*)data
;
2689 static u64 work64
[3];
2692 spin_lock(&i2o_proc_lock
);
2696 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2697 0x0281, -1, &work64
, 3*8, &i2o_proc_token
);
2700 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2701 spin_unlock(&i2o_proc_lock
);
2705 len
+= sprintf(buf
, "Rx overrun : " FMT_U64_HEX
"\n",
2706 U64_VAL(&work64
[0]));
2707 len
+= sprintf(buf
, "Tx underrun : " FMT_U64_HEX
"\n",
2708 U64_VAL(&work64
[1]));
2709 len
+= sprintf(buf
, "Tx heartbeat failure : " FMT_U64_HEX
"\n",
2710 U64_VAL(&work64
[2]));
2712 spin_unlock(&i2o_proc_lock
);
2716 /* LAN group 0300h - Required Token Ring Statistics (scalar) */
2717 int i2o_proc_read_lan_tr_stats(char *buf
, char **start
, off_t offset
,
2718 int len
, int *eof
, void *data
)
2720 struct i2o_device
*d
= (struct i2o_device
*)data
;
2721 static u64 work64
[13];
2724 static char *ring_status
[] =
2736 "Auto-Removal Error 1",
2744 spin_lock(&i2o_proc_lock
);
2748 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2749 0x0300, -1, &work64
, 13*8, &i2o_proc_token
);
2752 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2753 spin_unlock(&i2o_proc_lock
);
2757 len
+= sprintf(buf
, "LineErrors : " FMT_U64_HEX
"\n",
2758 U64_VAL(&work64
[0]));
2759 len
+= sprintf(buf
+len
, "LostFrames : " FMT_U64_HEX
"\n",
2760 U64_VAL(&work64
[1]));
2761 len
+= sprintf(buf
+len
, "ACError : " FMT_U64_HEX
"\n",
2762 U64_VAL(&work64
[2]));
2763 len
+= sprintf(buf
+len
, "TxAbortDelimiter : " FMT_U64_HEX
"\n",
2764 U64_VAL(&work64
[3]));
2765 len
+= sprintf(buf
+len
, "BursErrors : " FMT_U64_HEX
"\n",
2766 U64_VAL(&work64
[4]));
2767 len
+= sprintf(buf
+len
, "FrameCopiedErrors : " FMT_U64_HEX
"\n",
2768 U64_VAL(&work64
[5]));
2769 len
+= sprintf(buf
+len
, "FrequencyErrors : " FMT_U64_HEX
"\n",
2770 U64_VAL(&work64
[6]));
2771 len
+= sprintf(buf
+len
, "InternalErrors : " FMT_U64_HEX
"\n",
2772 U64_VAL(&work64
[7]));
2773 len
+= sprintf(buf
+len
, "LastRingStatus : %s\n", ring_status
[work64
[8]]);
2774 len
+= sprintf(buf
+len
, "TokenError : " FMT_U64_HEX
"\n",
2775 U64_VAL(&work64
[9]));
2776 len
+= sprintf(buf
+len
, "UpstreamNodeAddress : " FMT_U64_HEX
"\n",
2777 U64_VAL(&work64
[10]));
2778 len
+= sprintf(buf
+len
, "LastRingID : " FMT_U64_HEX
"\n",
2779 U64_VAL(&work64
[11]));
2780 len
+= sprintf(buf
+len
, "LastBeaconType : " FMT_U64_HEX
"\n",
2781 U64_VAL(&work64
[12]));
2783 spin_unlock(&i2o_proc_lock
);
2787 /* LAN group 0400h - Required FDDI Statistics (scalar) */
2788 int i2o_proc_read_lan_fddi_stats(char *buf
, char **start
, off_t offset
,
2789 int len
, int *eof
, void *data
)
2791 struct i2o_device
*d
= (struct i2o_device
*)data
;
2792 static u64 work64
[11];
2795 static char *conf_state
[] =
2812 static char *ring_state
[] =
2824 static char *link_state
[] =
2838 spin_lock(&i2o_proc_lock
);
2842 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2843 0x0400, -1, &work64
, 11*8, &i2o_proc_token
);
2846 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2847 spin_unlock(&i2o_proc_lock
);
2851 len
+= sprintf(buf
, "ConfigurationState : %s\n", conf_state
[work64
[0]]);
2852 len
+= sprintf(buf
+len
, "UpstreamNode : " FMT_U64_HEX
"\n",
2853 U64_VAL(&work64
[1]));
2854 len
+= sprintf(buf
+len
, "DownStreamNode : " FMT_U64_HEX
"\n",
2855 U64_VAL(&work64
[2]));
2856 len
+= sprintf(buf
+len
, "FrameErrors : " FMT_U64_HEX
"\n",
2857 U64_VAL(&work64
[3]));
2858 len
+= sprintf(buf
+len
, "FramesLost : " FMT_U64_HEX
"\n",
2859 U64_VAL(&work64
[4]));
2860 len
+= sprintf(buf
+len
, "RingMgmtState : %s\n", ring_state
[work64
[5]]);
2861 len
+= sprintf(buf
+len
, "LCTFailures: " FMT_U64_HEX
"\n",
2862 U64_VAL(&work64
[6]));
2863 len
+= sprintf(buf
+len
, "LEMRejects : " FMT_U64_HEX
"\n",
2864 U64_VAL(&work64
[7]));
2865 len
+= sprintf(buf
+len
, "LEMCount : " FMT_U64_HEX
"\n",
2866 U64_VAL(&work64
[8]));
2867 len
+= sprintf(buf
+len
, "LConnectionState : %s\n",
2868 link_state
[work64
[9]]);
2870 spin_unlock(&i2o_proc_lock
);
2874 static int i2o_proc_create_entries(void *data
, i2o_proc_entry
*pentry
,
2875 struct proc_dir_entry
*parent
)
2877 struct proc_dir_entry
*ent
;
2879 while(pentry
->name
!= NULL
)
2881 ent
= create_proc_entry(pentry
->name
, pentry
->mode
, parent
);
2885 ent
->read_proc
= pentry
->read_proc
;
2886 ent
->write_proc
= pentry
->write_proc
;
2895 static void i2o_proc_remove_entries(i2o_proc_entry
*pentry
,
2896 struct proc_dir_entry
*parent
)
2898 while(pentry
->name
!= NULL
)
2900 remove_proc_entry(pentry
->name
, parent
);
2905 static int i2o_proc_add_controller(struct i2o_controller
*pctrl
,
2906 struct proc_dir_entry
*root
)
2908 struct proc_dir_entry
*dir
, *dir1
;
2909 struct i2o_device
*dev
;
2912 sprintf(buff
, "iop%d", pctrl
->unit
);
2914 dir
= create_proc_entry(buff
, S_IFDIR
, root
);
2918 pctrl
->proc_entry
= dir
;
2920 i2o_proc_create_entries(pctrl
, generic_iop_entries
, dir
);
2922 for(dev
= pctrl
->devices
; dev
; dev
= dev
->next
)
2924 sprintf(buff
, "%0#5x", dev
->id
);
2926 dir1
= create_proc_entry(buff
, S_IFDIR
, dir
);
2927 dev
->proc_entry
= dir1
;
2930 printk(KERN_INFO
"i2o_proc: Could not allocate proc dir\n");
2932 i2o_proc_create_entries(dev
, generic_dev_entries
, dir1
);
2936 case I2O_CLASS_SCSI_PERIPHERAL
:
2937 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
2938 i2o_proc_create_entries(dev
, rbs_dev_entries
, dir1
);
2941 i2o_proc_create_entries(dev
, lan_entries
, dir1
);
2942 switch(dev
->subclass
)
2944 case I2O_LAN_ETHERNET
:
2945 i2o_proc_create_entries(dev
, lan_eth_entries
,
2949 i2o_proc_create_entries(dev
, lan_fddi_entries
,
2953 i2o_proc_create_entries(dev
, lan_tr_entries
,
2968 static void i2o_proc_remove_controller(struct i2o_controller
*pctrl
,
2969 struct proc_dir_entry
*parent
)
2973 struct proc_dir_entry
*de
;
2974 struct i2o_device
*dev
;
2976 /* Remove unused device entries */
2977 for(dev
=pctrl
->devices
; dev
; dev
=dev
->next
)
2980 sprintf(dev_id
, "%0#5x", dev
->id
);
2982 /* Would it be safe to remove _files_ even if they are in use? */
2983 if((de
) && (!de
->count
))
2985 i2o_proc_remove_entries(generic_dev_entries
, de
);
2989 case I2O_CLASS_SCSI_PERIPHERAL
:
2990 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
2991 i2o_proc_remove_entries(rbs_dev_entries
, de
);
2994 i2o_proc_remove_entries(lan_entries
, de
);
2995 switch(dev
->subclass
)
2997 case I2O_LAN_ETHERNET
:
2998 i2o_proc_remove_entries(lan_eth_entries
, de
);
3001 i2o_proc_remove_entries(lan_fddi_entries
, de
);
3004 i2o_proc_remove_entries(lan_tr_entries
, de
);
3008 remove_proc_entry(dev_id
, parent
);
3012 if(!pctrl
->proc_entry
->count
)
3014 sprintf(buff
, "iop%d", pctrl
->unit
);
3016 i2o_proc_remove_entries(generic_iop_entries
, pctrl
->proc_entry
);
3018 remove_proc_entry(buff
, parent
);
3019 pctrl
->proc_entry
= NULL
;
3023 static int create_i2o_procfs(void)
3025 struct i2o_controller
*pctrl
= NULL
;
3028 i2o_proc_dir_root
= create_proc_entry("i2o", S_IFDIR
, 0);
3029 if(!i2o_proc_dir_root
)
3032 for(i
= 0; i
< MAX_I2O_CONTROLLERS
; i
++)
3034 pctrl
= i2o_find_controller(i
);
3037 i2o_proc_add_controller(pctrl
, i2o_proc_dir_root
);
3038 i2o_unlock_controller(pctrl
);
3045 static int destroy_i2o_procfs(void)
3047 struct i2o_controller
*pctrl
= NULL
;
3050 if(!i2o_find_controller(0))
3053 for(i
= 0; i
< MAX_I2O_CONTROLLERS
; i
++)
3055 pctrl
= i2o_find_controller(i
);
3058 i2o_proc_remove_controller(pctrl
, i2o_proc_dir_root
);
3059 i2o_unlock_controller(pctrl
);
3063 if(!i2o_proc_dir_root
->count
)
3064 remove_proc_entry("i2o", 0);
3072 #define i2o_proc_init init_module
3075 __init
int i2o_proc_init(void)
3077 if(create_i2o_procfs())
3080 if (i2o_install_handler(&i2o_proc_handler
) < 0)
3082 printk(KERN_ERR
"i2o_proc: Unable to install PROC handler.\n");
3086 proc_context
= i2o_proc_handler
.context
;
3094 MODULE_AUTHOR("Deepak Saxena");
3095 MODULE_DESCRIPTION("I2O procfs Handler");
3097 void cleanup_module(void)
3099 destroy_i2o_procfs();
3100 i2o_remove_handler(&i2o_proc_handler
);