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/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>
51 #include <asm/uaccess.h>
52 #include <asm/byteorder.h>
60 * Structure used to define /proc entries
62 typedef struct _i2o_proc_entry_t
64 char *name
; /* entry name */
65 mode_t mode
; /* mode */
66 read_proc_t
*read_proc
; /* read func */
67 write_proc_t
*write_proc
; /* write func */
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 *,
102 static int i2o_proc_read_lan_mac_addr(char *, char **, off_t
, int, int *,
104 static int i2o_proc_read_lan_mcast_addr(char *, char **, off_t
, int, int *,
106 static int i2o_proc_read_lan_batch_control(char *, char **, off_t
, int, int *,
108 static int i2o_proc_read_lan_operation(char *, char **, off_t
, int, int *,
110 static int i2o_proc_read_lan_media_operation(char *, char **, off_t
, int,
112 static int i2o_proc_read_lan_alt_addr(char *, char **, off_t
, int, int *,
114 static int i2o_proc_read_lan_tx_info(char *, char **, off_t
, int, int *,
116 static int i2o_proc_read_lan_rx_info(char *, char **, off_t
, int, int *,
118 static int i2o_proc_read_lan_hist_stats(char *, char **, off_t
, int, int *,
120 static int i2o_proc_read_lan_supp_opt_stats(char *, char **, off_t
, int, int *,
122 static int i2o_proc_read_lan_opt_tx_hist_stats(char *, char **, off_t
, int,
124 static int i2o_proc_read_lan_opt_rx_hist_stats(char *, char **, off_t
, int,
126 static int i2o_proc_read_lan_eth_stats(char *, char **, off_t
, int,
128 static int i2o_proc_read_lan_supp_eth_stats(char *, char **, off_t
, int, int *,
130 static int i2o_proc_read_lan_opt_eth_stats(char *, char **, off_t
, int, int *,
132 static int i2o_proc_read_lan_tr_stats(char *, char **, off_t
, int, int *,
134 static int i2o_proc_read_lan_fddi_stats(char *, char **, off_t
, int, int *,
137 static struct proc_dir_entry
*i2o_proc_dir_root
;
142 static struct i2o_handler i2o_proc_handler
=
144 (void *)i2o_proc_reply
,
147 0xffffffff // All classes
151 * IOP specific entries...write field just in case someone
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",
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"
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
)
290 return strncat(tmp
, (char *)chars
, n
);
293 static char* bus_strings
[] =
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
;
325 spin_lock(&i2o_proc_lock
);
329 workspace
= kmalloc(2048, GFP_KERNEL
);
330 hrt
= (pi2o_hrt
)workspace
;
333 len
+= sprintf(buf
, "No free memory for HRT buffer\n");
334 spin_unlock(&i2o_proc_lock
);
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
;
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
)
351 len
+= sprintf(buf
, "Timeout waiting for HRT\n");
352 spin_unlock(&i2o_proc_lock
);
359 len
+= sprintf(buf
+len
,
360 "HRT table for controller is too new a version.\n");
361 spin_unlock(&i2o_proc_lock
);
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");
370 len
+= sprintf(buf
+len
,
371 "HRT table too big to fit in buffer.\n");
372 spin_unlock(&i2o_proc_lock
);
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
]);
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
);
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
);
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
);
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
);
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
);
444 len
+= sprintf(buf
+len
, " Unsupported Bus Type\n");
448 len
+= sprintf(buf
+len
, " Unknown Bus Type\n");
453 spin_unlock(&i2o_proc_lock
);
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
;
464 pi2o_lct lct
; /* = (pi2o_lct)c->lct; */
469 #define BUS_TABLE_SIZE 3
470 static char *bus_ports
[] =
477 spin_lock(&i2o_proc_lock
);
481 workspace
= kmalloc(8192, GFP_KERNEL
);
482 lct
= (pi2o_lct
)workspace
;
485 len
+= sprintf(buf
, "No free memory for LCT buffer\n");
486 spin_unlock(&i2o_proc_lock
);
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
;
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
)
505 len
+= sprintf(buf
, "Timeout waiting for LCT\n");
506 spin_unlock(&i2o_proc_lock
);
510 entries
= (lct
->table_size
- 3)/9;
512 len
+= sprintf(buf
, "LCT contains %d %s\n", entries
,
513 entries
== 1 ? "entry" : "entries");
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
)
532 len
+= sprintf(buf
+len
, ": Direct-Access Read/Write");
536 len
+= sprintf(buf
+len
, ": WORM Drive");
540 len
+= sprintf(buf
+len
, ": CD-ROM Drive");
544 len
+= sprintf(buf
+len
, ": Optical Memory Device");
548 len
+= sprintf(buf
+len
, ": Unknown (0x%02x)",
549 lct
->lct_entry
[i
].sub_class
);
555 switch(lct
->lct_entry
[i
].sub_class
& 0xFF)
558 len
+= sprintf(buf
+len
, ": Ethernet");
562 len
+= sprintf(buf
+len
, ": 100base VG");
566 len
+= sprintf(buf
+len
, ": IEEE 802.5/Token-Ring");
570 len
+= sprintf(buf
+len
, ": ANSI X3T9.5 FDDI");
574 len
+= sprintf(buf
+len
, ": Fibre Channel");
578 len
+= sprintf(buf
+len
, ": Unknown Sub-Class (0x%02x)",
579 lct
->lct_entry
[i
].sub_class
& 0xFF);
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
]);
589 len
+= sprintf(buf
+len
, ": Unknown Device Type");
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
]);
597 len
+= sprintf(buf
+len
, ": Unknown Bus Type");
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
);
622 spin_unlock(&i2o_proc_lock
);
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
;
640 spin_lock(&i2o_proc_lock
);
644 workspace
= (u8
*)kmalloc(88, GFP_KERNEL
);
647 len
+= sprintf(buf
, "No memory for status transfer\n");
648 spin_unlock(&i2o_proc_lock
);
652 m
= I2O_POST_READ32(c
);
655 len
+= sprintf(buf
, "Could not get inbound message frame from IOP!\n");
657 spin_unlock(&i2o_proc_lock
);
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 */
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
);
682 while(workspace
[87] != 0xFF)
684 if(jiffies
-time
>= 2*HZ
)
686 len
+= sprintf(buf
, "Timeout waiting for status reply\n");
688 spin_unlock(&i2o_proc_lock
);
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]) {
702 len
+= sprintf(buf
+len
, "1.0\n");
705 len
+= sprintf(buf
+len
, "1.5\n");
708 len
+= sprintf(buf
+len
, "2.0\n");
712 len
+= sprintf(buf
+len
, "Highest I2O version supported: ");
713 switch(workspace
[3]) {
715 len
+= sprintf(buf
+len
, "1.0\n");
718 len
+= sprintf(buf
+len
, "1.5\n");
721 len
+= sprintf(buf
+len
, "2.0\n");
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: ");
734 len
+= sprintf(buf
+len
, "1.0\n");
737 len
+= sprintf(buf
+len
, "1.5\n");
740 len
+= sprintf(buf
+len
, "2.0\n");
743 len
+= sprintf(buf
+len
, "Unknown version\n");
746 len
+= sprintf(buf
+len
, "IOP State: ");
747 switch(workspace
[10])
750 len
+= sprintf(buf
+len
, "Init\n");
754 len
+= sprintf(buf
+len
, "Reset\n");
758 len
+= sprintf(buf
+len
, "Hold\n");
762 len
+= sprintf(buf
+len
, "Hold\n");
766 len
+= sprintf(buf
+len
, "Operational\n");
770 len
+= sprintf(buf
+len
, "FAILED\n");
774 len
+= sprintf(buf
+len
, "FAULTED\n");
778 len
+= sprintf(buf
+len
, "Unknown\n");
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])
788 len
+= sprintf(buf
+len
, "Memory mapped\n");
791 len
+= sprintf(buf
+len
, "Memory mapped only\n");
794 len
+= sprintf(buf
+len
, "Remote only\n");
797 len
+= sprintf(buf
+len
, "Memory mapped and remote\n");
800 len
+= sprintf(buf
+len
, "Unknown\n");
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);
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",
817 len
+= sprintf(buf
+len
, "Allocated private memory space: %d kB\n",
819 len
+= sprintf(buf
+len
, "Private memory base address: %0#10x\n",
821 len
+= sprintf(buf
+len
, "Desired private I/O space: %d kB\n",
823 len
+= sprintf(buf
+len
, "Allocated private I/O space: %d kB\n",
825 len
+= sprintf(buf
+len
, "Private I/O base address: %0#10x\n",
829 spin_unlock(&i2o_proc_lock
);
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
;
844 static char *cpu_table
[] =
846 "Intel 80960 series",
848 "Motorola 68000 series",
856 spin_lock(&i2o_proc_lock
);
860 token
= i2o_query_scalar(c
, ADAPTER_TID
, proc_context
,
861 0, // ParamGroup 0x0000h
869 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
870 spin_unlock(&i2o_proc_lock
);
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);
882 len
+= sprintf(buf
+len
, "Capabilities :\n");
884 len
+= sprintf(buf
+len
, " Self-booting\n");
886 len
+= sprintf(buf
+len
, " Upgradable IRTOS\n");
888 len
+= sprintf(buf
+len
, " Supports downloading DDMs\n");
890 len
+= sprintf(buf
+len
, " Supports installing DDMs\n");
892 len
+= sprintf(buf
+len
, " Battery-backed RAM\n");
894 len
+= sprintf(buf
+len
, "CPU : ");
896 len
+= sprintf(buf
+len
, "Unknown\n");
898 len
+= sprintf(buf
+len
, "%s\n", cpu_table
[work8
[16]]);
899 /* Anyone using ProcessorVersion? */
901 spin_unlock(&i2o_proc_lock
);
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
;
915 typedef struct _i2o_exec_execute_ddm_table
{
922 u8 module_version
[4];
925 } i2o_exec_execute_ddm_table
, *pi2o_exec_execute_ddm_table
;
936 i2o_exec_execute_ddm_table ddm_table
[MAX_I2O_MODULES
];
939 i2o_exec_execute_ddm_table ddm_table
;
941 spin_lock(&i2o_proc_lock
);
944 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
945 c
, ADAPTER_TID
, proc_context
,
948 &result
, sizeof(result
), &i2o_proc_token
);
954 len
+= sprintf(buf
, "Timeout reading table.\n");
955 spin_unlock(&i2o_proc_lock
);
959 len
+= sprintf(buf
, "No free memory to read the table.\n");
960 spin_unlock(&i2o_proc_lock
);
964 len
+= sprintf(buf
, "Error reading group. BlockStatus %d\n",
966 spin_unlock(&i2o_proc_lock
);
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
)
980 len
+= sprintf(buf
+len
, "Downloaded DDM ");
983 len
+= sprintf(buf
+len
, "Embedded DDM ");
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
);
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
;
1013 spin_lock(&i2o_proc_lock
);
1017 token
= i2o_query_scalar(c
, ADAPTER_TID
, proc_context
, 0x0004, -1,
1018 &work32
, sizeof(work32
), &i2o_proc_token
);
1022 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1023 spin_unlock(&i2o_proc_lock
);
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
);
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
;
1049 u8 module_name_version
[28];
1054 } i2o_driver_store_table
;
1056 struct i2o_controller
*c
= (struct i2o_controller
*)data
;
1069 i2o_driver_store_table dst
[MAX_I2O_MODULES
];
1072 i2o_driver_store_table dst
;
1074 spin_lock(&i2o_proc_lock
);
1078 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
1079 c
, ADAPTER_TID
, proc_context
,
1082 &result
, sizeof(result
), &i2o_proc_token
);
1088 len
+= sprintf(buf
, "Timeout reading table.\n");
1089 spin_unlock(&i2o_proc_lock
);
1093 len
+= sprintf(buf
, "No free memory to read the table.\n");
1094 spin_unlock(&i2o_proc_lock
);
1098 len
+= sprintf(buf
, "Error reading group. "
1099 "BlockStatus %d\n",token
);
1100 spin_unlock(&i2o_proc_lock
);
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
)
1112 len
+= sprintf(buf
+len
, "Downloaded DDM ");
1115 len
+= sprintf(buf
+len
, "Embedded DDM ");
1118 len
+= sprintf(buf
+len
, " ");
1122 if(c
->i2oversion
== 0x02)
1123 len
+= sprintf(buf
+len
, "%-d", dst
.module_state
);
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
);
1134 if(c
->i2oversion
== 0x02)
1135 len
+= sprintf(buf
+len
, "%d",
1136 dst
.notification_level
);
1138 len
+= sprintf(buf
+len
, "\n");
1141 spin_unlock(&i2o_proc_lock
);
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
;
1159 spin_lock(&i2o_proc_lock
);
1163 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
1164 c
, ADAPTER_TID
, proc_context
,
1167 &work16
, sizeof(work16
), &i2o_proc_token
);
1173 len
+= sprintf(buf
, "Timeout reading table.\n");
1174 spin_unlock(&i2o_proc_lock
);
1178 len
+= sprintf(buf
, "No free memory to read the table.\n");
1179 spin_unlock(&i2o_proc_lock
);
1183 len
+= sprintf(buf
, "Error reading table. BlockStatus %d\n",
1185 spin_unlock(&i2o_proc_lock
);
1192 len
+= sprintf(buf
+len
, "\nPARAMS DESCRIPTOR TABLE:\n\n");
1193 len
+= sprintf(buf
+len
, "# Group FieldCount RowCount Type Add Del Clear\n");
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]);
1206 len
+= sprintf(buf
+len
, "Table ");
1208 len
+= sprintf(buf
+len
, "Scalar ");
1210 len
+= sprintf(buf
+len
, "x ");
1212 len
+= sprintf(buf
+len
, " ");
1214 len
+= sprintf(buf
+len
, "x ");
1216 len
+= sprintf(buf
+len
, " ");
1218 len
+= sprintf(buf
+len
, "x ");
1220 len
+= sprintf(buf
+len
, " ");
1222 len
+= sprintf(buf
+len
, "\n");
1226 len
+= sprintf(buf
+len
, "There is more...\n");
1228 spin_unlock(&i2o_proc_lock
);
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
;
1246 spin_lock(&i2o_proc_lock
);
1250 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
1251 c
, ADAPTER_TID
, proc_context
,
1254 &work16
, sizeof(work16
), &i2o_proc_token
);
1260 len
+= sprintf(buf
, "Timeout reading table.\n");
1261 spin_unlock(&i2o_proc_lock
);
1265 len
+= sprintf(buf
, "No free memory to read the table.\n");
1266 spin_unlock(&i2o_proc_lock
);
1270 len
+= sprintf(buf
, "Error reading field. BlockStatus %d\n",
1272 spin_unlock(&i2o_proc_lock
);
1279 len
+= sprintf(buf
+len
, "Instance# OrgId FunctionCode\n");
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");
1292 len
+= sprintf(buf
+len
, "There is more...\n");
1294 spin_unlock(&i2o_proc_lock
);
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
;
1309 spin_lock(&i2o_proc_lock
);
1313 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1314 0xF100, // ParamGroup F100h (Device Identity)
1322 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1323 spin_unlock(&i2o_proc_lock
);
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
,
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
);
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' )
1359 len
= sprintf(buf
, "%s\n", d
->dev_name
);
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
;
1374 spin_lock(&i2o_proc_lock
);
1378 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1379 0xF101, // ParamGroup F101h (DDM Identity)
1387 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1388 spin_unlock(&i2o_proc_lock
);
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
,
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
);
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];
1418 spin_lock(&i2o_proc_lock
);
1422 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1423 0xF102, // ParamGroup F102h (User Information)
1431 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1432 spin_unlock(&i2o_proc_lock
);
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
);
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
;
1456 spin_lock(&i2o_proc_lock
);
1460 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1461 0xF103, // ParamGroup F103h (SGL Operating Limits)
1469 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1470 spin_unlock(&i2o_proc_lock
);
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
);
1503 static int print_serial_number(char *buff
, int pos
, u8
*serialno
, int max_len
)
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
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
]);
1527 case I2O_SNFORMAT_ASCII
: /* ASCII */
1528 if ( serialno
[1] < ' ' ) /* printable or SNLen? */
1531 max_len
= (max_len
< serialno
[1]) ? max_len
: serialno
[1];
1532 serialno
[1+max_len
] = '\0';
1535 pos
+= sprintf(buff
+pos
, "%s", &serialno
[2]);
1539 /* print chars for specified length */
1540 for(i
= 0; i
< serialno
[1]; i
++)
1542 pos
+= sprintf(buff
+pos
, "%c", serialno
[2+i
]);
1547 case I2O_SNFORMAT_UNICODE
: /* UNICODE */
1548 pos
+= sprintf(buff
+pos
, "UNICODE Format. Can't Display\n");
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]);
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");
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]);
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]);
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]);
1596 case I2O_SNFORMAT_UNKNOWN
: /* Unknown 0 */
1597 case I2O_SNFORMAT_UNKNOWN2
: /* Unknown 0xff */
1599 pos
+= sprintf(buff
+pos
, "Unknown data format (0x%02x)",
1607 const char * i2o_get_connector_type(int conn
)
1610 static char *i2o_connector_type
[] = {
1681 return i2o_connector_type
[idx
];
1685 const char * i2o_get_connection_type(int conn
)
1688 static char *i2o_connection_type
[] = {
1722 case I2O_LAN_UNKNOWN
:
1728 case I2O_LAN_10BASE5
:
1734 case I2O_LAN_10BASE2
:
1737 case I2O_LAN_10BROAD36
:
1740 case I2O_LAN_10BASE_T
:
1743 case I2O_LAN_10BASE_FP
:
1746 case I2O_LAN_10BASE_FB
:
1749 case I2O_LAN_10BASE_FL
:
1752 case I2O_LAN_100BASE_TX
:
1755 case I2O_LAN_100BASE_FX
:
1758 case I2O_LAN_100BASE_T4
:
1761 case I2O_LAN_1000BASE_SX
:
1764 case I2O_LAN_1000BASE_LX
:
1767 case I2O_LAN_1000BASE_CX
:
1770 case I2O_LAN_1000BASE_T
:
1773 case I2O_LAN_100VG_ETHERNET
:
1776 case I2O_LAN_100VG_TR
:
1782 case I2O_LAN_16MBIT
:
1785 case I2O_LAN_125MBAUD
:
1788 case I2O_LAN_POINT_POINT
:
1791 case I2O_LAN_ARB_LOOP
:
1794 case I2O_LAN_PUBLIC_LOOP
:
1797 case I2O_LAN_FABRIC
:
1800 case I2O_LAN_EMULATION
:
1806 case I2O_LAN_DEFAULT
:
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
;
1826 spin_lock(&i2o_proc_lock
);
1830 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1831 0x0000, -1, &work32
, 56*4, &i2o_proc_token
);
1834 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1835 spin_unlock(&i2o_proc_lock
);
1839 len
+= sprintf(buf
, "LAN Type : ");
1843 len
+= sprintf(buf
+len
, "Ethernet, ");
1846 len
+= sprintf(buf
+len
, "100Base VG, ");
1849 len
+= sprintf(buf
+len
, "Token Ring, ");
1852 len
+= sprintf(buf
+len
, "FDDI, ");
1855 len
+= sprintf(buf
+len
, "Fibre Channel, ");
1858 len
+= sprintf(buf
+len
, "Unknown type (0x%04x), ", work16
[0]);
1862 if (work16
[1]&0x00000001)
1863 len
+= sprintf(buf
+len
, "emulated LAN, ");
1865 len
+= sprintf(buf
+len
, "physical LAN port, ");
1867 if (work16
[1]&0x00000002)
1868 len
+= sprintf(buf
+len
, "full duplex\n");
1870 len
+= sprintf(buf
+len
, "simplex\n");
1872 len
+= sprintf(buf
+len
, "Address format : ");
1875 len
+= sprintf(buf
+len
, "IEEE 48bit\n");
1878 len
+= sprintf(buf
+len
, "FC IEEE\n");
1881 len
+= sprintf(buf
+len
, "Unknown (0x%02x)\n", work8
[4]);
1885 len
+= sprintf(buf
+len
, "State : ");
1889 len
+= sprintf(buf
+len
, "Unknown\n");
1892 len
+= sprintf(buf
+len
, "Unclaimed\n");
1895 len
+= sprintf(buf
+len
, "Operational\n");
1898 len
+= sprintf(buf
+len
, "Suspended\n");
1901 len
+= sprintf(buf
+len
, "Resetting\n");
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");
1914 len
+= sprintf(buf
+len
, "Operational no Rx\n");
1917 len
+= sprintf(buf
+len
, "Suspended no Rx\n");
1920 len
+= sprintf(buf
+len
, "Unspecified\n");
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
);
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
;
1950 spin_lock(&i2o_proc_lock
);
1953 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
1954 0x0001, -1, &work32
, 48*4, &i2o_proc_token
);
1957 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
1958 spin_unlock(&i2o_proc_lock
);
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");
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",
2020 len
+= sprintf(buf
+len
, "Imperfect filtering for max %d multicast addresses\n",
2023 spin_unlock(&i2o_proc_lock
);
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
;
2039 spin_lock(&i2o_proc_lock
);
2042 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
2043 d
->controller
, d
->id
, proc_context
, 0x0002, -1,
2044 NULL
, 0, &field32
, sizeof(field32
),
2050 len
+= sprintf(buf
, "Timeout reading table.\n");
2051 spin_unlock(&i2o_proc_lock
);
2055 len
+= sprintf(buf
, "No free memory to read the table.\n");
2056 spin_unlock(&i2o_proc_lock
);
2060 len
+= sprintf(buf
, "Error reading field. BlockStatus %d\n",
2062 spin_unlock(&i2o_proc_lock
);
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
);
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];
2093 spin_lock(&i2o_proc_lock
);
2096 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2097 0x0003, -1, &work32
, 9*4, &i2o_proc_token
);
2100 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2101 spin_unlock(&i2o_proc_lock
);
2105 len
+= sprintf(buf
, "Batch mode ");
2106 if (work32
[0]&0x00000001)
2107 len
+= sprintf(buf
+len
, "disabled");
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");
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",
2121 len
+= sprintf(buf
+len
, "Rising load threshold : %d ms\n",
2123 len
+= sprintf(buf
+len
, "Falling load delay : %d ms\n",
2125 len
+= sprintf(buf
+len
, "Falling load threshold : %d ms\n",
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",
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
);
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];
2153 spin_lock(&i2o_proc_lock
);
2156 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2157 0x0004, -1, &work32
, 20, &i2o_proc_token
);
2160 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2161 spin_unlock(&i2o_proc_lock
);
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");
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
);
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
;
2218 spin_lock(&i2o_proc_lock
);
2221 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2222 0x0005, -1, &work32
, 36, &i2o_proc_token
);
2225 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2226 spin_unlock(&i2o_proc_lock
);
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");
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]) {
2260 len
+= sprintf(buf
+len
, "Half duplex\n");
2263 len
+= sprintf(buf
+len
, "Full duplex\n");
2266 len
+= sprintf(buf
+len
, "\n");
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
);
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
;
2291 spin_lock(&i2o_proc_lock
);
2294 token
= i2o_query_table(I2O_PARAMS_TABLE_GET
,
2295 d
->controller
, d
->id
, proc_context
, 0x0006, -1,
2296 NULL
, 0, &field32
, sizeof(field32
),
2302 len
+= sprintf(buf
, "Timeout reading table.\n");
2303 spin_unlock(&i2o_proc_lock
);
2307 len
+= sprintf(buf
, "No free memory to read the table.\n");
2308 spin_unlock(&i2o_proc_lock
);
2312 len
+= sprintf(buf
, "Error reading field. BlockStatus %d\n",
2314 spin_unlock(&i2o_proc_lock
);
2318 len
+= sprintf(buf
,"RowCount=%d, MoreFlag=%d\n", field16
[0],
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
);
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];
2346 spin_lock(&i2o_proc_lock
);
2349 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2350 0x0007, -1, &work32
, 8*4, &i2o_proc_token
);
2353 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2354 spin_unlock(&i2o_proc_lock
);
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");
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
);
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];
2408 spin_lock(&i2o_proc_lock
);
2411 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2412 0x0008, -1, &work32
, 8*4, &i2o_proc_token
);
2415 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2416 spin_unlock(&i2o_proc_lock
);
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
);
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];
2443 spin_lock(&i2o_proc_lock
);
2446 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2447 0x0100, -1, &work64
, 9*8, &i2o_proc_token
);
2450 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2451 spin_unlock(&i2o_proc_lock
);
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
);
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];
2487 spin_lock(&i2o_proc_lock
);
2491 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2492 0x0180, -1, &work64
, 4*8, &i2o_proc_token
);
2495 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2496 spin_unlock(&i2o_proc_lock
);
2500 if (d
->i2oversion
== 0x00)
2501 len
+= sprintf(buf
, "Supported stats : " FMT_U64_HEX
" \n",
2502 U64_VAL(&work64
[0]));
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
);
2518 /* LAN group 0182h - Optional Non Media Specific Transmit Historical Statistics
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];
2527 spin_lock(&i2o_proc_lock
);
2531 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2532 0x0182, -1, &work64
, 9*8, &i2o_proc_token
);
2535 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2536 spin_unlock(&i2o_proc_lock
);
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
);
2563 /* LAN group 0183h - Optional Non Media Specific Receive Historical Statistics
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];
2572 spin_lock(&i2o_proc_lock
);
2576 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2577 0x0183, -1, &work64
, 11*8, &i2o_proc_token
);
2580 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2581 spin_unlock(&i2o_proc_lock
);
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
);
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];
2621 spin_lock(&i2o_proc_lock
);
2625 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2626 0x0200, -1, &work64
, 8*8, &i2o_proc_token
);
2629 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2630 spin_unlock(&i2o_proc_lock
);
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
);
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];
2663 spin_lock(&i2o_proc_lock
);
2667 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2668 0x0280, -1, &work64
, 8, &i2o_proc_token
);
2671 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2672 spin_unlock(&i2o_proc_lock
);
2676 len
+= sprintf(buf
, "Supported stats : " FMT_U64_HEX
"\n",
2677 U64_VAL(&work64
[0]));
2679 spin_unlock(&i2o_proc_lock
);
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];
2691 spin_lock(&i2o_proc_lock
);
2695 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2696 0x0281, -1, &work64
, 3*8, &i2o_proc_token
);
2699 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2700 spin_unlock(&i2o_proc_lock
);
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
);
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];
2723 static char *ring_status
[] =
2735 "Auto-Removal Error 1",
2743 spin_lock(&i2o_proc_lock
);
2747 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2748 0x0300, -1, &work64
, 13*8, &i2o_proc_token
);
2751 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2752 spin_unlock(&i2o_proc_lock
);
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
);
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];
2794 static char *conf_state
[] =
2811 static char *ring_state
[] =
2823 static char *link_state
[] =
2837 spin_lock(&i2o_proc_lock
);
2841 token
= i2o_query_scalar(d
->controller
, d
->id
, proc_context
,
2842 0x0400, -1, &work64
, 11*8, &i2o_proc_token
);
2845 len
+= sprintf(buf
, "Timeout waiting for reply from IOP\n");
2846 spin_unlock(&i2o_proc_lock
);
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
);
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
);
2884 ent
->read_proc
= pentry
->read_proc
;
2885 ent
->write_proc
= pentry
->write_proc
;
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
);
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
;
2911 sprintf(buff
, "iop%d", pctrl
->unit
);
2913 dir
= create_proc_entry(buff
, S_IFDIR
, root
);
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
;
2929 printk(KERN_INFO
"i2o_proc: Could not allocate proc dir\n");
2931 i2o_proc_create_entries(dev
, generic_dev_entries
, dir1
);
2935 case I2O_CLASS_SCSI_PERIPHERAL
:
2936 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
2937 i2o_proc_create_entries(dev
, rbs_dev_entries
, dir1
);
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
,
2948 i2o_proc_create_entries(dev
, lan_fddi_entries
,
2952 i2o_proc_create_entries(dev
, lan_tr_entries
,
2967 static void i2o_proc_remove_controller(struct i2o_controller
*pctrl
,
2968 struct proc_dir_entry
*parent
)
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
)
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
);
2988 case I2O_CLASS_SCSI_PERIPHERAL
:
2989 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
2990 i2o_proc_remove_entries(rbs_dev_entries
, de
);
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
);
3000 i2o_proc_remove_entries(lan_fddi_entries
, de
);
3003 i2o_proc_remove_entries(lan_tr_entries
, de
);
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
;
3027 i2o_proc_dir_root
= create_proc_entry("i2o", S_IFDIR
, 0);
3028 if(!i2o_proc_dir_root
)
3031 for(i
= 0; i
< MAX_I2O_CONTROLLERS
; i
++)
3033 pctrl
= i2o_find_controller(i
);
3036 i2o_proc_add_controller(pctrl
, i2o_proc_dir_root
);
3037 i2o_unlock_controller(pctrl
);
3044 static int destroy_i2o_procfs(void)
3046 struct i2o_controller
*pctrl
= NULL
;
3049 if(!i2o_find_controller(0))
3052 for(i
= 0; i
< MAX_I2O_CONTROLLERS
; i
++)
3054 pctrl
= i2o_find_controller(i
);
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);
3071 #define i2o_proc_init init_module
3074 __init
int i2o_proc_init(void)
3076 if(create_i2o_procfs())
3079 if (i2o_install_handler(&i2o_proc_handler
) < 0)
3081 printk(KERN_ERR
"i2o_proc: Unable to install PROC handler.\n");
3085 proc_context
= i2o_proc_handler
.context
;
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
);