i2o_proc.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:92k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *   procfs handler for Linux I2O subsystem
  3.  *
  4.  *   (c) Copyright 1999 Deepak Saxena
  5.  *   
  6.  *   Originally written by Deepak Saxena(deepak@plexity.net)
  7.  *
  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.
  12.  *
  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.
  16.  *
  17.  *   DISCLAIMER: This code is still under development/test and may cause
  18.  *   your system to behave unpredictably.  Use at your own discretion.
  19.  *
  20.  *   LAN entries by Juha Siev鋘en (Juha.Sievanen@cs.Helsinki.FI),
  21.  *     Auvo H鋕kinen (Auvo.Hakkinen@cs.Helsinki.FI)
  22.  *   University of Helsinki, Department of Computer Science
  23.  *
  24.  *   Some cleanup (c) 2002 Red Hat <alan@redhat.com>
  25.  *   Working to make I2O 64bit safe and following the PCI API
  26.  *
  27.  *   TODO List
  28.  * - Clean up code to use official structure definitions 
  29.  */
  30. // FIXME!
  31. #define FMT_U64_HEX "0x%08x%08x"
  32. #define U64_VAL(pu64) *((u32*)(pu64)+1), *((u32*)(pu64))
  33. #include <linux/types.h>
  34. #include <linux/kernel.h>
  35. #include <linux/pci.h>
  36. #include <linux/i2o.h>
  37. #include <linux/proc_fs.h>
  38. #include <linux/init.h>
  39. #include <linux/module.h>
  40. #include <linux/errno.h>
  41. #include <linux/spinlock.h>
  42. #include <asm/io.h>
  43. #include <asm/uaccess.h>
  44. #include <asm/byteorder.h>
  45. #include "i2o_lan.h"
  46. /*
  47.  * Structure used to define /proc entries
  48.  */
  49. typedef struct _i2o_proc_entry_t
  50. {
  51. char *name; /* entry name */
  52. mode_t mode; /* mode */
  53. read_proc_t *read_proc; /* read func */
  54. write_proc_t *write_proc; /* write func */
  55. } i2o_proc_entry;
  56. // #define DRIVERDEBUG
  57. static int i2o_proc_read_lct(char *, char **, off_t, int, int *, void *);
  58. static int i2o_proc_read_hrt(char *, char **, off_t, int, int *, void *);
  59. static int i2o_proc_read_status(char *, char **, off_t, int, int *, void *);
  60. static int i2o_proc_read_hw(char *, char **, off_t, int, int *, void *);
  61. static int i2o_proc_read_ddm_table(char *, char **, off_t, int, int *, void *);
  62. static int i2o_proc_read_driver_store(char *, char **, off_t, int, int *, void *);
  63. static int i2o_proc_read_drivers_stored(char *, char **, off_t, int, int *, void *);
  64. static int i2o_proc_read_groups(char *, char **, off_t, int, int *, void *);
  65. static int i2o_proc_read_phys_device(char *, char **, off_t, int, int *, void *);
  66. static int i2o_proc_read_claimed(char *, char **, off_t, int, int *, void *);
  67. static int i2o_proc_read_users(char *, char **, off_t, int, int *, void *);
  68. static int i2o_proc_read_priv_msgs(char *, char **, off_t, int, int *, void *);
  69. static int i2o_proc_read_authorized_users(char *, char **, off_t, int, int *, void *);
  70. static int i2o_proc_read_dev_name(char *, char **, off_t, int, int *, void *);
  71. static int i2o_proc_read_dev_identity(char *, char **, off_t, int, int *, void *);
  72. static int i2o_proc_read_ddm_identity(char *, char **, off_t, int, int *, void *);
  73. static int i2o_proc_read_uinfo(char *, char **, off_t, int, int *, void *);
  74. static int i2o_proc_read_sgl_limits(char *, char **, off_t, int, int *, void *);
  75. static int i2o_proc_read_sensors(char *, char **, off_t, int, int *, void *);
  76. static int print_serial_number(char *, int, u8 *, int);
  77. static int i2o_proc_create_entries(void *, i2o_proc_entry *,
  78.    struct proc_dir_entry *);
  79. static void i2o_proc_remove_entries(i2o_proc_entry *, struct proc_dir_entry *);
  80. static int i2o_proc_add_controller(struct i2o_controller *, 
  81.    struct proc_dir_entry * );
  82. static void i2o_proc_remove_controller(struct i2o_controller *, 
  83.        struct proc_dir_entry * );
  84. static void i2o_proc_add_device(struct i2o_device *, struct proc_dir_entry *);
  85. static void i2o_proc_remove_device(struct i2o_device *);
  86. static int create_i2o_procfs(void);
  87. static int destroy_i2o_procfs(void);
  88. static void i2o_proc_new_dev(struct i2o_controller *, struct i2o_device *);
  89. static void i2o_proc_dev_del(struct i2o_controller *, struct i2o_device *);
  90. static int i2o_proc_read_lan_dev_info(char *, char **, off_t, int, int *,
  91.       void *);
  92. static int i2o_proc_read_lan_mac_addr(char *, char **, off_t, int, int *,
  93.       void *);
  94. static int i2o_proc_read_lan_mcast_addr(char *, char **, off_t, int, int *,
  95. void *);
  96. static int i2o_proc_read_lan_batch_control(char *, char **, off_t, int, int *,
  97.    void *);
  98. static int i2o_proc_read_lan_operation(char *, char **, off_t, int, int *,
  99.        void *);
  100. static int i2o_proc_read_lan_media_operation(char *, char **, off_t, int,
  101.      int *, void *);
  102. static int i2o_proc_read_lan_alt_addr(char *, char **, off_t, int, int *,
  103.       void *);
  104. static int i2o_proc_read_lan_tx_info(char *, char **, off_t, int, int *,
  105.      void *);
  106. static int i2o_proc_read_lan_rx_info(char *, char **, off_t, int, int *,
  107.      void *);
  108. static int i2o_proc_read_lan_hist_stats(char *, char **, off_t, int, int *,
  109. void *);
  110. static int i2o_proc_read_lan_eth_stats(char *, char **, off_t, int,
  111.        int *, void *);
  112. static int i2o_proc_read_lan_tr_stats(char *, char **, off_t, int, int *,
  113.       void *);
  114. static int i2o_proc_read_lan_fddi_stats(char *, char **, off_t, int, int *,
  115. void *);
  116. static struct proc_dir_entry *i2o_proc_dir_root;
  117. /*
  118.  * I2O OSM descriptor
  119.  */
  120. static struct i2o_handler i2o_proc_handler =
  121. {
  122. NULL,
  123. i2o_proc_new_dev,
  124. i2o_proc_dev_del,
  125. NULL,
  126. "I2O procfs Layer",
  127. 0,
  128. 0xffffffff // All classes
  129. };
  130. /*
  131.  * IOP specific entries...write field just in case someone 
  132.  * ever wants one.
  133.  */
  134. static i2o_proc_entry generic_iop_entries[] = 
  135. {
  136. {"hrt", S_IFREG|S_IRUGO, i2o_proc_read_hrt, NULL},
  137. {"lct", S_IFREG|S_IRUGO, i2o_proc_read_lct, NULL},
  138. {"status", S_IFREG|S_IRUGO, i2o_proc_read_status, NULL},
  139. {"hw", S_IFREG|S_IRUGO, i2o_proc_read_hw, NULL},
  140. {"ddm_table", S_IFREG|S_IRUGO, i2o_proc_read_ddm_table, NULL},
  141. {"driver_store", S_IFREG|S_IRUGO, i2o_proc_read_driver_store, NULL},
  142. {"drivers_stored", S_IFREG|S_IRUGO, i2o_proc_read_drivers_stored, NULL},
  143. {NULL, 0, NULL, NULL}
  144. };
  145. /*
  146.  * Device specific entries
  147.  */
  148. static i2o_proc_entry generic_dev_entries[] = 
  149. {
  150. {"groups", S_IFREG|S_IRUGO, i2o_proc_read_groups, NULL},
  151. {"phys_dev", S_IFREG|S_IRUGO, i2o_proc_read_phys_device, NULL},
  152. {"claimed", S_IFREG|S_IRUGO, i2o_proc_read_claimed, NULL},
  153. {"users", S_IFREG|S_IRUGO, i2o_proc_read_users, NULL},
  154. {"priv_msgs", S_IFREG|S_IRUGO, i2o_proc_read_priv_msgs, NULL},
  155. {"authorized_users", S_IFREG|S_IRUGO, i2o_proc_read_authorized_users, NULL},
  156. {"dev_identity", S_IFREG|S_IRUGO, i2o_proc_read_dev_identity, NULL},
  157. {"ddm_identity", S_IFREG|S_IRUGO, i2o_proc_read_ddm_identity, NULL},
  158. {"user_info", S_IFREG|S_IRUGO, i2o_proc_read_uinfo, NULL},
  159. {"sgl_limits", S_IFREG|S_IRUGO, i2o_proc_read_sgl_limits, NULL},
  160. {"sensors", S_IFREG|S_IRUGO, i2o_proc_read_sensors, NULL},
  161. {NULL, 0, NULL, NULL}
  162. };
  163. /*
  164.  *  Storage unit specific entries (SCSI Periph, BS) with device names
  165.  */
  166. static i2o_proc_entry rbs_dev_entries[] = 
  167. {
  168. {"dev_name", S_IFREG|S_IRUGO, i2o_proc_read_dev_name, NULL},
  169. {NULL, 0, NULL, NULL}
  170. };
  171. #define SCSI_TABLE_SIZE 13
  172. static char *scsi_devices[] = 
  173. {
  174. "Direct-Access Read/Write",
  175. "Sequential-Access Storage",
  176. "Printer",
  177. "Processor",
  178. "WORM Device",
  179. "CD-ROM Device",
  180. "Scanner Device",
  181. "Optical Memory Device",
  182. "Medium Changer Device",
  183. "Communications Device",
  184. "Graphics Art Pre-Press Device",
  185. "Graphics Art Pre-Press Device",
  186. "Array Controller Device"
  187. };
  188. /* private */
  189. /*
  190.  * Generic LAN specific entries
  191.  * 
  192.  * Should groups with r/w entries have their own subdirectory?
  193.  *
  194.  */
  195. static i2o_proc_entry lan_entries[] = 
  196. {
  197. {"lan_dev_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_dev_info, NULL},
  198. {"lan_mac_addr", S_IFREG|S_IRUGO, i2o_proc_read_lan_mac_addr, NULL},
  199. {"lan_mcast_addr", S_IFREG|S_IRUGO|S_IWUSR,
  200.  i2o_proc_read_lan_mcast_addr, NULL},
  201. {"lan_batch_ctrl", S_IFREG|S_IRUGO|S_IWUSR,
  202.  i2o_proc_read_lan_batch_control, NULL},
  203. {"lan_operation", S_IFREG|S_IRUGO, i2o_proc_read_lan_operation, NULL},
  204. {"lan_media_operation", S_IFREG|S_IRUGO,
  205.  i2o_proc_read_lan_media_operation, NULL},
  206. {"lan_alt_addr", S_IFREG|S_IRUGO, i2o_proc_read_lan_alt_addr, NULL},
  207. {"lan_tx_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_tx_info, NULL},
  208. {"lan_rx_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_rx_info, NULL},
  209. {"lan_hist_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_hist_stats, NULL},
  210. {NULL, 0, NULL, NULL}
  211. };
  212. /*
  213.  * Port specific LAN entries
  214.  * 
  215.  */
  216. static i2o_proc_entry lan_eth_entries[] = 
  217. {
  218. {"lan_eth_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_eth_stats, NULL},
  219. {NULL, 0, NULL, NULL}
  220. };
  221. static i2o_proc_entry lan_tr_entries[] = 
  222. {
  223. {"lan_tr_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_tr_stats, NULL},
  224. {NULL, 0, NULL, NULL}
  225. };
  226. static i2o_proc_entry lan_fddi_entries[] = 
  227. {
  228. {"lan_fddi_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_fddi_stats, NULL},
  229. {NULL, 0, NULL, NULL}
  230. };
  231. static char *chtostr(u8 *chars, int n)
  232. {
  233. char tmp[256];
  234. tmp[0] = 0;
  235.         return strncat(tmp, (char *)chars, n);
  236. }
  237. static int i2o_report_query_status(char *buf, int block_status, char *group)
  238. {
  239. switch (block_status)
  240. {
  241. case -ETIMEDOUT:
  242. return sprintf(buf, "Timeout reading group %s.n",group);
  243. case -ENOMEM:
  244. return sprintf(buf, "No free memory to read the table.n");
  245. case -I2O_PARAMS_STATUS_INVALID_GROUP_ID:
  246. return sprintf(buf, "Group %s not supported.n", group);
  247. default:
  248. return sprintf(buf, "Error reading group %s. BlockStatus 0x%02Xn",
  249.        group, -block_status);
  250. }
  251. }
  252. static char* bus_strings[] = 
  253. "Local Bus", 
  254. "ISA", 
  255. "EISA", 
  256. "MCA", 
  257. "PCI",
  258. "PCMCIA", 
  259. "NUBUS", 
  260. "CARDBUS"
  261. };
  262. static spinlock_t i2o_proc_lock = SPIN_LOCK_UNLOCKED;
  263. int i2o_proc_read_hrt(char *buf, char **start, off_t offset, int count, 
  264.       int *eof, void *data)
  265. {
  266. struct i2o_controller *c = (struct i2o_controller *)data;
  267. i2o_hrt *hrt = (i2o_hrt *)c->hrt;
  268. u32 bus;
  269. int len, i;
  270. spin_lock(&i2o_proc_lock);
  271. len = 0;
  272. if(hrt->hrt_version)
  273. {
  274. len += sprintf(buf+len, 
  275.        "HRT table for controller is too new a version.n");
  276. spin_unlock(&i2o_proc_lock);
  277. return len;
  278. }
  279. if((hrt->num_entries * hrt->entry_len + 8) > 2048) {
  280. printk(KERN_WARNING "i2o_proc: HRT does not fit into buffern");
  281. len += sprintf(buf+len,
  282.        "HRT table too big to fit in buffer.n");
  283. spin_unlock(&i2o_proc_lock);
  284. return len;
  285. }
  286. len += sprintf(buf+len, "HRT has %d entries of %d bytes each.n",
  287.        hrt->num_entries, hrt->entry_len << 2);
  288. for(i = 0; i < hrt->num_entries && len < count; i++)
  289. {
  290. len += sprintf(buf+len, "Entry %d:n", i);
  291. len += sprintf(buf+len, "   Adapter ID: %0#10xn", 
  292. hrt->hrt_entry[i].adapter_id);
  293. len += sprintf(buf+len, "   Controlling tid: %0#6xn",
  294. hrt->hrt_entry[i].parent_tid);
  295. if(hrt->hrt_entry[i].bus_type != 0x80)
  296. {
  297. bus = hrt->hrt_entry[i].bus_type;
  298. len += sprintf(buf+len, "   %s Informationn", bus_strings[bus]);
  299. switch(bus)
  300. {
  301. case I2O_BUS_LOCAL:
  302. len += sprintf(buf+len, "     IOBase: %0#6x,",
  303. hrt->hrt_entry[i].bus.local_bus.LbBaseIOPort);
  304. len += sprintf(buf+len, " MemoryBase: %0#10xn",
  305. hrt->hrt_entry[i].bus.local_bus.LbBaseMemoryAddress);
  306. break;
  307. case I2O_BUS_ISA:
  308. len += sprintf(buf+len, "     IOBase: %0#6x,",
  309. hrt->hrt_entry[i].bus.isa_bus.IsaBaseIOPort);
  310. len += sprintf(buf+len, " MemoryBase: %0#10x,",
  311. hrt->hrt_entry[i].bus.isa_bus.IsaBaseMemoryAddress);
  312. len += sprintf(buf+len, " CSN: %0#4x,",
  313. hrt->hrt_entry[i].bus.isa_bus.CSN);
  314. break;
  315. case I2O_BUS_EISA:
  316. len += sprintf(buf+len, "     IOBase: %0#6x,",
  317. hrt->hrt_entry[i].bus.eisa_bus.EisaBaseIOPort);
  318. len += sprintf(buf+len, " MemoryBase: %0#10x,",
  319. hrt->hrt_entry[i].bus.eisa_bus.EisaBaseMemoryAddress);
  320. len += sprintf(buf+len, " Slot: %0#4x,",
  321. hrt->hrt_entry[i].bus.eisa_bus.EisaSlotNumber);
  322. break;
  323.  
  324. case I2O_BUS_MCA:
  325. len += sprintf(buf+len, "     IOBase: %0#6x,",
  326. hrt->hrt_entry[i].bus.mca_bus.McaBaseIOPort);
  327. len += sprintf(buf+len, " MemoryBase: %0#10x,",
  328. hrt->hrt_entry[i].bus.mca_bus.McaBaseMemoryAddress);
  329. len += sprintf(buf+len, " Slot: %0#4x,",
  330. hrt->hrt_entry[i].bus.mca_bus.McaSlotNumber);
  331. break;
  332. case I2O_BUS_PCI:
  333. len += sprintf(buf+len, "     Bus: %0#4x",
  334. hrt->hrt_entry[i].bus.pci_bus.PciBusNumber);
  335. len += sprintf(buf+len, " Dev: %0#4x",
  336. hrt->hrt_entry[i].bus.pci_bus.PciDeviceNumber);
  337. len += sprintf(buf+len, " Func: %0#4x",
  338. hrt->hrt_entry[i].bus.pci_bus.PciFunctionNumber);
  339. len += sprintf(buf+len, " Vendor: %0#6x",
  340. hrt->hrt_entry[i].bus.pci_bus.PciVendorID);
  341. len += sprintf(buf+len, " Device: %0#6xn",
  342. hrt->hrt_entry[i].bus.pci_bus.PciDeviceID);
  343. break;
  344. default:
  345. len += sprintf(buf+len, "      Unsupported Bus Typen");
  346. }
  347. }
  348. else
  349. len += sprintf(buf+len, "   Unknown Bus Typen");
  350. }
  351. spin_unlock(&i2o_proc_lock);
  352. return len;
  353. }
  354. int i2o_proc_read_lct(char *buf, char **start, off_t offset, int len,
  355. int *eof, void *data)
  356. {
  357. struct i2o_controller *c = (struct i2o_controller*)data;
  358. i2o_lct *lct = (i2o_lct *)c->lct;
  359. int entries;
  360. int i;
  361. #define BUS_TABLE_SIZE 3
  362. static char *bus_ports[] =
  363. {
  364. "Generic Bus",
  365. "SCSI Bus",
  366. "Fibre Channel Bus"
  367. };
  368. spin_lock(&i2o_proc_lock);
  369. len = 0;
  370. entries = (lct->table_size - 3)/9;
  371. len += sprintf(buf, "LCT contains %d %sn", entries,
  372. entries == 1 ? "entry" : "entries");
  373. if(lct->boot_tid)
  374. len += sprintf(buf+len, "Boot Device @ ID %dn", lct->boot_tid);
  375. len += 
  376. sprintf(buf+len, "Current Change Indicator: %#10xn", lct->change_ind);
  377. for(i = 0; i < entries; i++)
  378. {
  379. len += sprintf(buf+len, "Entry %dn", i);
  380. len += sprintf(buf+len, "  Class, SubClass  : %s", i2o_get_class_name(lct->lct_entry[i].class_id));
  381. /*
  382.  * Classes which we'll print subclass info for
  383.  */
  384. switch(lct->lct_entry[i].class_id & 0xFFF)
  385. {
  386. case I2O_CLASS_RANDOM_BLOCK_STORAGE:
  387. switch(lct->lct_entry[i].sub_class)
  388. {
  389. case 0x00:
  390. len += sprintf(buf+len, ", Direct-Access Read/Write");
  391. break;
  392. case 0x04:
  393. len += sprintf(buf+len, ", WORM Drive");
  394. break;
  395. case 0x05:
  396. len += sprintf(buf+len, ", CD-ROM Drive");
  397. break;
  398. case 0x07:
  399. len += sprintf(buf+len, ", Optical Memory Device");
  400. break;
  401. default:
  402. len += sprintf(buf+len, ", Unknown (0x%02x)",
  403.        lct->lct_entry[i].sub_class);
  404. break;
  405. }
  406. break;
  407. case I2O_CLASS_LAN:
  408. switch(lct->lct_entry[i].sub_class & 0xFF)
  409. {
  410. case 0x30:
  411. len += sprintf(buf+len, ", Ethernet");
  412. break;
  413. case 0x40:
  414. len += sprintf(buf+len, ", 100base VG");
  415. break;
  416. case 0x50:
  417. len += sprintf(buf+len, ", IEEE 802.5/Token-Ring");
  418. break;
  419. case 0x60:
  420. len += sprintf(buf+len, ", ANSI X3T9.5 FDDI");
  421. break;
  422. case 0x70:
  423. len += sprintf(buf+len, ", Fibre Channel");
  424. break;
  425. default:
  426. len += sprintf(buf+len, ", Unknown Sub-Class (0x%02x)",
  427.        lct->lct_entry[i].sub_class & 0xFF);
  428. break;
  429. }
  430. break;
  431. case I2O_CLASS_SCSI_PERIPHERAL:
  432. if(lct->lct_entry[i].sub_class < SCSI_TABLE_SIZE)
  433. len += sprintf(buf+len, ", %s", 
  434. scsi_devices[lct->lct_entry[i].sub_class]);
  435. else
  436. len += sprintf(buf+len, ", Unknown Device Type");
  437. break;
  438. case I2O_CLASS_BUS_ADAPTER_PORT:
  439. if(lct->lct_entry[i].sub_class < BUS_TABLE_SIZE)
  440. len += sprintf(buf+len, ", %s", 
  441. bus_ports[lct->lct_entry[i].sub_class]);
  442. else
  443. len += sprintf(buf+len, ", Unknown Bus Type");
  444. break;
  445. }
  446. len += sprintf(buf+len, "n");
  447. len += sprintf(buf+len, "  Local TID        : 0x%03xn", lct->lct_entry[i].tid);
  448. len += sprintf(buf+len, "  User TID         : 0x%03xn", lct->lct_entry[i].user_tid);
  449. len += sprintf(buf+len, "  Parent TID       : 0x%03xn", 
  450. lct->lct_entry[i].parent_tid);
  451. len += sprintf(buf+len, "  Identity Tag     : 0x%x%x%x%x%x%x%x%xn",
  452. lct->lct_entry[i].identity_tag[0],
  453. lct->lct_entry[i].identity_tag[1],
  454. lct->lct_entry[i].identity_tag[2],
  455. lct->lct_entry[i].identity_tag[3],
  456. lct->lct_entry[i].identity_tag[4],
  457. lct->lct_entry[i].identity_tag[5],
  458. lct->lct_entry[i].identity_tag[6],
  459. lct->lct_entry[i].identity_tag[7]);
  460. len += sprintf(buf+len, "  Change Indicator : %0#10xn", 
  461. lct->lct_entry[i].change_ind);
  462. len += sprintf(buf+len, "  Event Capab Mask : %0#10xn", 
  463. lct->lct_entry[i].device_flags);
  464. }
  465. spin_unlock(&i2o_proc_lock);
  466. return len;
  467. }
  468. int i2o_proc_read_status(char *buf, char **start, off_t offset, int len, 
  469.  int *eof, void *data)
  470. {
  471. struct i2o_controller *c = (struct i2o_controller*)data;
  472. char prodstr[25];
  473. int version;
  474. spin_lock(&i2o_proc_lock);
  475. len = 0;
  476. i2o_status_get(c); // reread the status block
  477. len += sprintf(buf+len,"Organization ID        : %0#6xn", 
  478. c->status_block->org_id);
  479. version = c->status_block->i2o_version;
  480. /* FIXME for Spec 2.0
  481. if (version == 0x02) {
  482. len += sprintf(buf+len,"Lowest I2O version supported: ");
  483. switch(workspace[2]) {
  484. case 0x00:
  485. len += sprintf(buf+len,"1.0n");
  486. break;
  487. case 0x01:
  488. len += sprintf(buf+len,"1.5n");
  489. break;
  490. case 0x02:
  491. len += sprintf(buf+len,"2.0n");
  492. break;
  493. }
  494. len += sprintf(buf+len, "Highest I2O version supported: ");
  495. switch(workspace[3]) {
  496. case 0x00:
  497. len += sprintf(buf+len,"1.0n");
  498. break;
  499. case 0x01:
  500. len += sprintf(buf+len,"1.5n");
  501. break;
  502. case 0x02:
  503. len += sprintf(buf+len,"2.0n");
  504. break;
  505. }
  506. }
  507. */
  508. len += sprintf(buf+len,"IOP ID                 : %0#5xn", 
  509. c->status_block->iop_id);
  510. len += sprintf(buf+len,"Host Unit ID           : %0#6xn",
  511. c->status_block->host_unit_id);
  512. len += sprintf(buf+len,"Segment Number         : %0#5xn",
  513. c->status_block->segment_number);
  514. len += sprintf(buf+len, "I2O version            : ");
  515. switch (version) {
  516. case 0x00:
  517. len += sprintf(buf+len,"1.0n");
  518. break;
  519. case 0x01:
  520. len += sprintf(buf+len,"1.5n");
  521. break;
  522. case 0x02:
  523. len += sprintf(buf+len,"2.0n");
  524. break;
  525. default:
  526. len += sprintf(buf+len,"Unknown versionn");
  527. }
  528. len += sprintf(buf+len, "IOP State              : ");
  529. switch (c->status_block->iop_state) {
  530. case 0x01:
  531. len += sprintf(buf+len,"INITn");
  532. break;
  533. case 0x02:
  534. len += sprintf(buf+len,"RESETn");
  535. break;
  536. case 0x04:
  537. len += sprintf(buf+len,"HOLDn");
  538. break;
  539. case 0x05:
  540. len += sprintf(buf+len,"READYn");
  541. break;
  542. case 0x08:
  543. len += sprintf(buf+len,"OPERATIONALn");
  544. break;
  545. case 0x10:
  546. len += sprintf(buf+len,"FAILEDn");
  547. break;
  548. case 0x11:
  549. len += sprintf(buf+len,"FAULTEDn");
  550. break;
  551. default:
  552. len += sprintf(buf+len,"Unknownn");
  553. break;
  554. }
  555. len += sprintf(buf+len,"Messenger Type         : ");
  556. switch (c->status_block->msg_type) { 
  557. case 0x00:
  558. len += sprintf(buf+len,"Memory mappedn");
  559. break;
  560. case 0x01:
  561. len += sprintf(buf+len,"Memory mapped onlyn");
  562. break;
  563. case 0x02:
  564. len += sprintf(buf+len,"Remote onlyn");
  565. break;
  566. case 0x03:
  567. len += sprintf(buf+len,"Memory mapped and remoten");
  568. break;
  569. default:
  570. len += sprintf(buf+len,"Unknownn");
  571. }
  572. len += sprintf(buf+len,"Inbound Frame Size     : %d bytesn", 
  573. c->status_block->inbound_frame_size<<2);
  574. len += sprintf(buf+len,"Max Inbound Frames     : %dn", 
  575. c->status_block->max_inbound_frames);
  576. len += sprintf(buf+len,"Current Inbound Frames : %dn", 
  577. c->status_block->cur_inbound_frames);
  578. len += sprintf(buf+len,"Max Outbound Frames    : %dn", 
  579. c->status_block->max_outbound_frames);
  580. /* Spec doesn't say if NULL terminated or not... */
  581. memcpy(prodstr, c->status_block->product_id, 24);
  582. prodstr[24] = '';
  583. len += sprintf(buf+len,"Product ID             : %sn", prodstr);
  584. len += sprintf(buf+len,"Expected LCT Size      : %d bytesn", 
  585. c->status_block->expected_lct_size);
  586. len += sprintf(buf+len,"IOP Capabilitiesn");
  587. len += sprintf(buf+len,"    Context Field Size Support : ");
  588. switch (c->status_block->iop_capabilities & 0x0000003) {
  589. case 0:
  590. len += sprintf(buf+len,"Supports only 32-bit context fieldsn");
  591. break;
  592. case 1:
  593. len += sprintf(buf+len,"Supports only 64-bit context fieldsn");
  594. break;
  595. case 2:
  596. len += sprintf(buf+len,"Supports 32-bit and 64-bit context fields, "
  597. "but not concurrentlyn");
  598. break;
  599. case 3:
  600. len += sprintf(buf+len,"Supports 32-bit and 64-bit context fields "
  601. "concurrentlyn");
  602. break;
  603. default:
  604. len += sprintf(buf+len,"0x%08xn",c->status_block->iop_capabilities);
  605. }
  606. len += sprintf(buf+len,"    Current Context Field Size : ");
  607. switch (c->status_block->iop_capabilities & 0x0000000C) {
  608. case 0:
  609. len += sprintf(buf+len,"not configuredn");
  610. break;
  611. case 4:
  612. len += sprintf(buf+len,"Supports only 32-bit context fieldsn");
  613. break;
  614. case 8:
  615. len += sprintf(buf+len,"Supports only 64-bit context fieldsn");
  616. break;
  617. case 12:
  618. len += sprintf(buf+len,"Supports both 32-bit or 64-bit context fields "
  619. "concurrentlyn");
  620. break;
  621. default:
  622. len += sprintf(buf+len,"n");
  623. }
  624. len += sprintf(buf+len,"    Inbound Peer Support       : %sn",
  625. (c->status_block->iop_capabilities & 0x00000010) ? "Supported" : "Not supported");
  626. len += sprintf(buf+len,"    Outbound Peer Support      : %sn",
  627. (c->status_block->iop_capabilities & 0x00000020) ? "Supported" : "Not supported");
  628. len += sprintf(buf+len,"    Peer to Peer Support       : %sn",
  629. (c->status_block->iop_capabilities & 0x00000040) ? "Supported" : "Not supported");
  630. len += sprintf(buf+len, "Desired private memory size   : %d kBn", 
  631. c->status_block->desired_mem_size>>10);
  632. len += sprintf(buf+len, "Allocated private memory size : %d kBn", 
  633. c->status_block->current_mem_size>>10);
  634. len += sprintf(buf+len, "Private memory base address   : %0#10xn", 
  635. c->status_block->current_mem_base);
  636. len += sprintf(buf+len, "Desired private I/O size      : %d kBn", 
  637. c->status_block->desired_io_size>>10);
  638. len += sprintf(buf+len, "Allocated private I/O size    : %d kBn", 
  639. c->status_block->current_io_size>>10);
  640. len += sprintf(buf+len, "Private I/O base address      : %0#10xn", 
  641. c->status_block->current_io_base);
  642. spin_unlock(&i2o_proc_lock);
  643. return len;
  644. }
  645. int i2o_proc_read_hw(char *buf, char **start, off_t offset, int len, 
  646.      int *eof, void *data)
  647. {
  648. struct i2o_controller *c = (struct i2o_controller*)data;
  649. static u32 work32[5];
  650. static u8 *work8 = (u8*)work32;
  651. static u16 *work16 = (u16*)work32;
  652. int token;
  653. u32 hwcap;
  654. static char *cpu_table[] =
  655. {
  656. "Intel 80960 series",
  657. "AMD2900 series",
  658. "Motorola 68000 series",
  659. "ARM series",
  660. "MIPS series",
  661. "Sparc series",
  662. "PowerPC series",
  663. "Intel x86 series"
  664. };
  665. spin_lock(&i2o_proc_lock);
  666. len = 0;
  667. token = i2o_query_scalar(c, ADAPTER_TID, 0x0000, -1, &work32, sizeof(work32));
  668. if (token < 0) {
  669. len += i2o_report_query_status(buf+len, token,"0x0000 IOP Hardware");
  670. spin_unlock(&i2o_proc_lock);
  671. return len;
  672. }
  673. len += sprintf(buf+len, "I2O Vendor ID    : %0#6xn", work16[0]);
  674. len += sprintf(buf+len, "Product ID       : %0#6xn", work16[1]);
  675. len += sprintf(buf+len, "CPU              : ");
  676. if(work8[16] > 8)
  677. len += sprintf(buf+len, "Unknownn");
  678. else
  679. len += sprintf(buf+len, "%sn", cpu_table[work8[16]]);
  680. /* Anyone using ProcessorVersion? */
  681. len += sprintf(buf+len, "RAM              : %dkBn", work32[1]>>10);
  682. len += sprintf(buf+len, "Non-Volatile Mem : %dkBn", work32[2]>>10);
  683. hwcap = work32[3];
  684. len += sprintf(buf+len, "Capabilities : 0x%08xn", hwcap);
  685. len += sprintf(buf+len, "   [%s] Self bootingn",
  686. (hwcap&0x00000001) ? "+" : "-");
  687. len += sprintf(buf+len, "   [%s] Upgradable IRTOSn",
  688. (hwcap&0x00000002) ? "+" : "-");
  689. len += sprintf(buf+len, "   [%s] Supports downloading DDMsn",
  690. (hwcap&0x00000004) ? "+" : "-");
  691. len += sprintf(buf+len, "   [%s] Supports installing DDMsn",
  692. (hwcap&0x00000008) ? "+" : "-");
  693. len += sprintf(buf+len, "   [%s] Battery-backed RAMn",
  694. (hwcap&0x00000010) ? "+" : "-");
  695. spin_unlock(&i2o_proc_lock);
  696. return len;
  697. }
  698. /* Executive group 0003h - Executing DDM List (table) */
  699. int i2o_proc_read_ddm_table(char *buf, char **start, off_t offset, int len, 
  700.     int *eof, void *data)
  701. {
  702. struct i2o_controller *c = (struct i2o_controller*)data;
  703. int token;
  704. int i;
  705. typedef struct _i2o_exec_execute_ddm_table {
  706. u16 ddm_tid;
  707. u8  module_type;
  708. u8  reserved;
  709. u16 i2o_vendor_id;
  710. u16 module_id;
  711. u8  module_name_version[28];
  712. u32 data_size;
  713. u32 code_size;
  714. } i2o_exec_execute_ddm_table;
  715. struct
  716. {
  717. u16 result_count;
  718. u16 pad;
  719. u16 block_size;
  720. u8  block_status;
  721. u8  error_info_size;
  722. u16 row_count;
  723. u16 more_flag;
  724. i2o_exec_execute_ddm_table ddm_table[MAX_I2O_MODULES];
  725. } result;
  726. i2o_exec_execute_ddm_table ddm_table;
  727. spin_lock(&i2o_proc_lock);
  728. len = 0;
  729. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  730. c, ADAPTER_TID, 
  731. 0x0003, -1,
  732. NULL, 0,
  733. &result, sizeof(result));
  734. if (token < 0) {
  735. len += i2o_report_query_status(buf+len, token,"0x0003 Executing DDM List");
  736. spin_unlock(&i2o_proc_lock);
  737. return len;
  738. }
  739. len += sprintf(buf+len, "Tid   Module_type     Vendor Mod_id  Module_name             Vrs  Data_size Code_sizen");
  740. ddm_table=result.ddm_table[0];
  741. for(i=0; i < result.row_count; ddm_table=result.ddm_table[++i])
  742. {
  743. len += sprintf(buf+len, "0x%03x ", ddm_table.ddm_tid & 0xFFF);
  744. switch(ddm_table.module_type)
  745. {
  746. case 0x01:
  747. len += sprintf(buf+len, "Downloaded DDM  ");
  748. break;
  749. case 0x22:
  750. len += sprintf(buf+len, "Embedded DDM    ");
  751. break;
  752. default:
  753. len += sprintf(buf+len, "                ");
  754. }
  755. len += sprintf(buf+len, "%-#7x", ddm_table.i2o_vendor_id);
  756. len += sprintf(buf+len, "%-#8x", ddm_table.module_id);
  757. len += sprintf(buf+len, "%-29s", chtostr(ddm_table.module_name_version, 28));
  758. len += sprintf(buf+len, "%9d  ", ddm_table.data_size);
  759. len += sprintf(buf+len, "%8d", ddm_table.code_size);
  760. len += sprintf(buf+len, "n");
  761. }
  762. spin_unlock(&i2o_proc_lock);
  763. return len;
  764. }
  765. /* Executive group 0004h - Driver Store (scalar) */
  766. int i2o_proc_read_driver_store(char *buf, char **start, off_t offset, int len, 
  767.      int *eof, void *data)
  768. {
  769. struct i2o_controller *c = (struct i2o_controller*)data;
  770. u32 work32[8];
  771. int token;
  772. spin_lock(&i2o_proc_lock);
  773. len = 0;
  774. token = i2o_query_scalar(c, ADAPTER_TID, 0x0004, -1, &work32, sizeof(work32));
  775. if (token < 0) {
  776. len += i2o_report_query_status(buf+len, token,"0x0004 Driver Store");
  777. spin_unlock(&i2o_proc_lock);
  778. return len;
  779. }
  780. len += sprintf(buf+len, "Module limit  : %dn"
  781. "Module count  : %dn"
  782. "Current space : %d kBn"
  783. "Free space    : %d kBn", 
  784. work32[0], work32[1], work32[2]>>10, work32[3]>>10);
  785. spin_unlock(&i2o_proc_lock);
  786. return len;
  787. }
  788. /* Executive group 0005h - Driver Store Table (table) */
  789. int i2o_proc_read_drivers_stored(char *buf, char **start, off_t offset,
  790.  int len, int *eof, void *data)
  791. {
  792. typedef struct _i2o_driver_store {
  793. u16 stored_ddm_index;
  794. u8  module_type;
  795. u8  reserved;
  796. u16 i2o_vendor_id;
  797. u16 module_id;
  798. u8  module_name_version[28];
  799. u8  date[8];
  800. u32 module_size;
  801. u32 mpb_size;
  802. u32 module_flags;
  803. } i2o_driver_store_table;
  804. struct i2o_controller *c = (struct i2o_controller*)data;
  805. int token;
  806. int i;
  807. typedef struct
  808. {
  809. u16 result_count;
  810. u16 pad;
  811. u16 block_size;
  812. u8  block_status;
  813. u8  error_info_size;
  814. u16 row_count;
  815. u16 more_flag;
  816. i2o_driver_store_table dst[MAX_I2O_MODULES];
  817. } i2o_driver_result_table;
  818. i2o_driver_result_table *result;
  819. i2o_driver_store_table *dst;
  820. len = 0;
  821. result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
  822. if(result == NULL)
  823. return -ENOMEM;
  824. spin_lock(&i2o_proc_lock);
  825. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  826. c, ADAPTER_TID, 0x0005, -1, NULL, 0, 
  827. result, sizeof(*result));
  828. if (token < 0) {
  829. len += i2o_report_query_status(buf+len, token,"0x0005 DRIVER STORE TABLE");
  830. spin_unlock(&i2o_proc_lock);
  831. kfree(result);
  832. return len;
  833. }
  834. len += sprintf(buf+len, "#  Module_type     Vendor Mod_id  Module_name             Vrs"  
  835. "Date     Mod_size Par_size Flagsn");
  836. for(i=0, dst=&result->dst[0]; i < result->row_count; dst=&result->dst[++i])
  837. {
  838. len += sprintf(buf+len, "%-3d", dst->stored_ddm_index);
  839. switch(dst->module_type)
  840. {
  841. case 0x01:
  842. len += sprintf(buf+len, "Downloaded DDM  ");
  843. break;
  844. case 0x22:
  845. len += sprintf(buf+len, "Embedded DDM    ");
  846. break;
  847. default:
  848. len += sprintf(buf+len, "                ");
  849. }
  850. #if 0
  851. if(c->i2oversion == 0x02)
  852. len += sprintf(buf+len, "%-d", dst->module_state);
  853. #endif
  854. len += sprintf(buf+len, "%-#7x", dst->i2o_vendor_id);
  855. len += sprintf(buf+len, "%-#8x", dst->module_id);
  856. len += sprintf(buf+len, "%-29s", chtostr(dst->module_name_version,28));
  857. len += sprintf(buf+len, "%-9s", chtostr(dst->date,8));
  858. len += sprintf(buf+len, "%8d ", dst->module_size);
  859. len += sprintf(buf+len, "%8d ", dst->mpb_size);
  860. len += sprintf(buf+len, "0x%04x", dst->module_flags);
  861. #if 0
  862. if(c->i2oversion == 0x02)
  863. len += sprintf(buf+len, "%d",
  864.        dst->notification_level);
  865. #endif
  866. len += sprintf(buf+len, "n");
  867. }
  868. spin_unlock(&i2o_proc_lock);
  869. kfree(result);
  870. return len;
  871. }
  872. /* Generic group F000h - Params Descriptor (table) */
  873. int i2o_proc_read_groups(char *buf, char **start, off_t offset, int len, 
  874.  int *eof, void *data)
  875. {
  876. struct i2o_device *d = (struct i2o_device*)data;
  877. int token;
  878. int i;
  879. u8 properties;
  880. typedef struct _i2o_group_info
  881. {
  882. u16 group_number;
  883. u16 field_count;
  884. u16 row_count;
  885. u8  properties;
  886. u8  reserved;
  887. } i2o_group_info;
  888. struct
  889. {
  890. u16 result_count;
  891. u16 pad;
  892. u16 block_size;
  893. u8  block_status;
  894. u8  error_info_size;
  895. u16 row_count;
  896. u16 more_flag;
  897. i2o_group_info group[256];
  898. } result;
  899. spin_lock(&i2o_proc_lock);
  900. len = 0;
  901. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  902. d->controller, d->lct_data.tid, 0xF000, -1, NULL, 0,
  903. &result, sizeof(result));
  904. if (token < 0) {
  905. len = i2o_report_query_status(buf+len, token, "0xF000 Params Descriptor");
  906. spin_unlock(&i2o_proc_lock);
  907. return len;
  908. }
  909. len += sprintf(buf+len, "#  Group   FieldCount RowCount Type   Add Del Clearn");
  910. for (i=0; i < result.row_count; i++)
  911. {
  912. len += sprintf(buf+len, "%-3d", i);
  913. len += sprintf(buf+len, "0x%04X ", result.group[i].group_number);
  914. len += sprintf(buf+len, "%10d ", result.group[i].field_count);
  915. len += sprintf(buf+len, "%8d ",  result.group[i].row_count);
  916. properties = result.group[i].properties;
  917. if (properties & 0x1) len += sprintf(buf+len, "Table  ");
  918. else len += sprintf(buf+len, "Scalar ");
  919. if (properties & 0x2) len += sprintf(buf+len, " + ");
  920. else len += sprintf(buf+len, " - ");
  921. if (properties & 0x4) len += sprintf(buf+len, "  + ");
  922. else len += sprintf(buf+len, "  - ");
  923. if (properties & 0x8) len += sprintf(buf+len, "  + ");
  924. else len += sprintf(buf+len, "  - ");
  925. len += sprintf(buf+len, "n");
  926. }
  927. if (result.more_flag)
  928. len += sprintf(buf+len, "There is more...n");
  929. spin_unlock(&i2o_proc_lock);
  930. return len;
  931. }
  932. /* Generic group F001h - Physical Device Table (table) */
  933. int i2o_proc_read_phys_device(char *buf, char **start, off_t offset, int len,
  934.       int *eof, void *data)
  935. {
  936. struct i2o_device *d = (struct i2o_device*)data;
  937. int token;
  938. int i;
  939. struct
  940. {
  941. u16 result_count;
  942. u16 pad;
  943. u16 block_size;
  944. u8  block_status;
  945. u8  error_info_size;
  946. u16 row_count;
  947. u16 more_flag;
  948. u32 adapter_id[64];
  949. } result;
  950. spin_lock(&i2o_proc_lock);
  951. len = 0;
  952. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  953. d->controller, d->lct_data.tid,
  954. 0xF001, -1, NULL, 0,
  955. &result, sizeof(result));
  956. if (token < 0) {
  957. len += i2o_report_query_status(buf+len, token,"0xF001 Physical Device Table");
  958. spin_unlock(&i2o_proc_lock);
  959. return len;
  960. }
  961. if (result.row_count)
  962. len += sprintf(buf+len, "#  AdapterIdn");
  963. for (i=0; i < result.row_count; i++)
  964. {
  965. len += sprintf(buf+len, "%-2d", i);
  966. len += sprintf(buf+len, "%#7xn", result.adapter_id[i]);
  967. }
  968. if (result.more_flag)
  969. len += sprintf(buf+len, "There is more...n");
  970. spin_unlock(&i2o_proc_lock);
  971. return len;
  972. }
  973. /* Generic group F002h - Claimed Table (table) */
  974. int i2o_proc_read_claimed(char *buf, char **start, off_t offset, int len,
  975.   int *eof, void *data)
  976. {
  977. struct i2o_device *d = (struct i2o_device*)data;
  978. int token;
  979. int i;
  980. struct {
  981. u16 result_count;
  982. u16 pad;
  983. u16 block_size;
  984. u8  block_status;
  985. u8  error_info_size;
  986. u16 row_count;
  987. u16 more_flag;
  988. u16 claimed_tid[64];
  989. } result;
  990. spin_lock(&i2o_proc_lock);
  991. len = 0;
  992. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  993. d->controller, d->lct_data.tid,
  994. 0xF002, -1, NULL, 0,
  995. &result, sizeof(result));
  996. if (token < 0) {
  997. len += i2o_report_query_status(buf+len, token,"0xF002 Claimed Table");
  998. spin_unlock(&i2o_proc_lock);
  999. return len;
  1000. }
  1001. if (result.row_count)
  1002. len += sprintf(buf+len, "#  ClaimedTidn");
  1003. for (i=0; i < result.row_count; i++)
  1004. {
  1005. len += sprintf(buf+len, "%-2d", i);
  1006. len += sprintf(buf+len, "%#7xn", result.claimed_tid[i]);
  1007. }
  1008. if (result.more_flag)
  1009. len += sprintf(buf+len, "There is more...n");
  1010. spin_unlock(&i2o_proc_lock);
  1011. return len;
  1012. }
  1013. /* Generic group F003h - User Table (table) */
  1014. int i2o_proc_read_users(char *buf, char **start, off_t offset, int len,
  1015. int *eof, void *data)
  1016. {
  1017. struct i2o_device *d = (struct i2o_device*)data;
  1018. int token;
  1019. int i;
  1020. typedef struct _i2o_user_table
  1021. {
  1022. u16 instance;
  1023. u16 user_tid;
  1024. u8 claim_type;
  1025. u8  reserved1;
  1026. u16  reserved2;
  1027. } i2o_user_table;
  1028. struct
  1029. {
  1030. u16 result_count;
  1031. u16 pad;
  1032. u16 block_size;
  1033. u8  block_status;
  1034. u8  error_info_size;
  1035. u16 row_count;
  1036. u16 more_flag;
  1037. i2o_user_table user[64];
  1038. } result;
  1039. spin_lock(&i2o_proc_lock);
  1040. len = 0;
  1041. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  1042. d->controller, d->lct_data.tid,
  1043. 0xF003, -1, NULL, 0,
  1044. &result, sizeof(result));
  1045. if (token < 0) {
  1046. len += i2o_report_query_status(buf+len, token,"0xF003 User Table");
  1047. spin_unlock(&i2o_proc_lock);
  1048. return len;
  1049. }
  1050. len += sprintf(buf+len, "#  Instance UserTid ClaimTypen");
  1051. for(i=0; i < result.row_count; i++)
  1052. {
  1053. len += sprintf(buf+len, "%-3d", i);
  1054. len += sprintf(buf+len, "%#8x ", result.user[i].instance);
  1055. len += sprintf(buf+len, "%#7x ", result.user[i].user_tid);
  1056. len += sprintf(buf+len, "%#9xn", result.user[i].claim_type);
  1057. }
  1058. if (result.more_flag)
  1059. len += sprintf(buf+len, "There is more...n");
  1060. spin_unlock(&i2o_proc_lock);
  1061. return len;
  1062. }
  1063. /* Generic group F005h - Private message extensions (table) (optional) */
  1064. int i2o_proc_read_priv_msgs(char *buf, char **start, off_t offset, int len, 
  1065.     int *eof, void *data)
  1066. {
  1067. struct i2o_device *d = (struct i2o_device*)data;
  1068. int token;
  1069. int i;
  1070. typedef struct _i2o_private
  1071. {
  1072. u16 ext_instance;
  1073. u16 organization_id;
  1074. u16 x_function_code;
  1075. } i2o_private;
  1076. struct
  1077. {
  1078. u16 result_count;
  1079. u16 pad;
  1080. u16 block_size;
  1081. u8  block_status;
  1082. u8  error_info_size;
  1083. u16 row_count;
  1084. u16 more_flag;
  1085. i2o_private extension[64];
  1086. } result;
  1087. spin_lock(&i2o_proc_lock);
  1088. len = 0;
  1089. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  1090. d->controller, d->lct_data.tid,
  1091. 0xF000, -1,
  1092. NULL, 0,
  1093. &result, sizeof(result));
  1094. if (token < 0) {
  1095. len += i2o_report_query_status(buf+len, token,"0xF005 Private Message Extensions (optional)");
  1096. spin_unlock(&i2o_proc_lock);
  1097. return len;
  1098. }
  1099. len += sprintf(buf+len, "Instance#  OrgId  FunctionCoden");
  1100. for(i=0; i < result.row_count; i++)
  1101. {
  1102. len += sprintf(buf+len, "%0#9x ", result.extension[i].ext_instance);
  1103. len += sprintf(buf+len, "%0#6x ", result.extension[i].organization_id);
  1104. len += sprintf(buf+len, "%0#6x",  result.extension[i].x_function_code);
  1105. len += sprintf(buf+len, "n");
  1106. }
  1107. if(result.more_flag)
  1108. len += sprintf(buf+len, "There is more...n");
  1109. spin_unlock(&i2o_proc_lock);
  1110. return len;
  1111. }
  1112. /* Generic group F006h - Authorized User Table (table) */
  1113. int i2o_proc_read_authorized_users(char *buf, char **start, off_t offset, int len,
  1114.    int *eof, void *data)
  1115. {
  1116. struct i2o_device *d = (struct i2o_device*)data;
  1117. int token;
  1118. int i;
  1119. struct
  1120. {
  1121. u16 result_count;
  1122. u16 pad;
  1123. u16 block_size;
  1124. u8  block_status;
  1125. u8  error_info_size;
  1126. u16 row_count;
  1127. u16 more_flag;
  1128. u32 alternate_tid[64];
  1129. } result;
  1130. spin_lock(&i2o_proc_lock);
  1131. len = 0;
  1132. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  1133. d->controller, d->lct_data.tid,
  1134. 0xF006, -1,
  1135. NULL, 0,
  1136. &result, sizeof(result));
  1137. if (token < 0) {
  1138. len += i2o_report_query_status(buf+len, token,"0xF006 Autohorized User Table");
  1139. spin_unlock(&i2o_proc_lock);
  1140. return len;
  1141. }
  1142. if (result.row_count)
  1143. len += sprintf(buf+len, "#  AlternateTidn");
  1144. for(i=0; i < result.row_count; i++)
  1145. {
  1146. len += sprintf(buf+len, "%-2d", i);
  1147. len += sprintf(buf+len, "%#7x ", result.alternate_tid[i]);
  1148. }
  1149. if (result.more_flag)
  1150. len += sprintf(buf+len, "There is more...n");
  1151. spin_unlock(&i2o_proc_lock);
  1152. return len;
  1153. }
  1154. /* Generic group F100h - Device Identity (scalar) */
  1155. int i2o_proc_read_dev_identity(char *buf, char **start, off_t offset, int len, 
  1156.        int *eof, void *data)
  1157. {
  1158. struct i2o_device *d = (struct i2o_device*)data;
  1159. static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
  1160. // == (allow) 512d bytes (max)
  1161. static u16 *work16 = (u16*)work32;
  1162. int token;
  1163. spin_lock(&i2o_proc_lock);
  1164. len = 0;
  1165. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  1166. 0xF100, -1,
  1167. &work32, sizeof(work32));
  1168. if (token < 0) {
  1169. len += i2o_report_query_status(buf+len, token ,"0xF100 Device Identity");
  1170. spin_unlock(&i2o_proc_lock);
  1171. return len;
  1172. }
  1173. len += sprintf(buf,     "Device Class  : %sn", i2o_get_class_name(work16[0]));
  1174. len += sprintf(buf+len, "Owner TID     : %0#5xn", work16[2]);
  1175. len += sprintf(buf+len, "Parent TID    : %0#5xn", work16[3]);
  1176. len += sprintf(buf+len, "Vendor info   : %sn", chtostr((u8 *)(work32+2), 16));
  1177. len += sprintf(buf+len, "Product info  : %sn", chtostr((u8 *)(work32+6), 16));
  1178. len += sprintf(buf+len, "Description   : %sn", chtostr((u8 *)(work32+10), 16));
  1179. len += sprintf(buf+len, "Product rev.  : %sn", chtostr((u8 *)(work32+14), 8));
  1180. len += sprintf(buf+len, "Serial number : ");
  1181. len = print_serial_number(buf, len,
  1182. (u8*)(work32+16),
  1183. /* allow for SNLen plus
  1184.  * possible trailing ''
  1185.  */
  1186. sizeof(work32)-(16*sizeof(u32))-2
  1187. );
  1188. len +=  sprintf(buf+len, "n");
  1189. spin_unlock(&i2o_proc_lock);
  1190. return len;
  1191. }
  1192. int i2o_proc_read_dev_name(char *buf, char **start, off_t offset, int len,
  1193. int *eof, void *data)
  1194. {
  1195. struct i2o_device *d = (struct i2o_device*)data;
  1196. if ( d->dev_name[0] == '' )
  1197. return 0;
  1198. len = sprintf(buf, "%sn", d->dev_name);
  1199. return len;
  1200. }
  1201. /* Generic group F101h - DDM Identity (scalar) */
  1202. int i2o_proc_read_ddm_identity(char *buf, char **start, off_t offset, int len, 
  1203.       int *eof, void *data)
  1204. {
  1205. struct i2o_device *d = (struct i2o_device*)data;
  1206. int token;
  1207. struct
  1208. {
  1209. u16 ddm_tid;
  1210. u8 module_name[24];
  1211. u8 module_rev[8];
  1212. u8 sn_format;
  1213. u8 serial_number[12];
  1214. u8 pad[256]; // allow up to 256 byte (max) serial number
  1215. } result;
  1216. spin_lock(&i2o_proc_lock);
  1217. len = 0;
  1218. token = i2o_query_scalar(d->controller, d->lct_data.tid, 
  1219. 0xF101, -1,
  1220. &result, sizeof(result));
  1221. if (token < 0) {
  1222. len += i2o_report_query_status(buf+len, token,"0xF101 DDM Identity");
  1223. spin_unlock(&i2o_proc_lock);
  1224. return len;
  1225. }
  1226. len += sprintf(buf,     "Registering DDM TID : 0x%03xn", result.ddm_tid);
  1227. len += sprintf(buf+len, "Module name         : %sn", chtostr(result.module_name, 24));
  1228. len += sprintf(buf+len, "Module revision     : %sn", chtostr(result.module_rev, 8));
  1229. len += sprintf(buf+len, "Serial number       : ");
  1230. len = print_serial_number(buf, len, result.serial_number, sizeof(result)-36);
  1231. /* allow for SNLen plus possible trailing '' */
  1232. len += sprintf(buf+len, "n");
  1233. spin_unlock(&i2o_proc_lock);
  1234. return len;
  1235. }
  1236. /* Generic group F102h - User Information (scalar) */
  1237. int i2o_proc_read_uinfo(char *buf, char **start, off_t offset, int len, 
  1238. int *eof, void *data)
  1239. {
  1240. struct i2o_device *d = (struct i2o_device*)data;
  1241. int token;
  1242.   struct
  1243. {
  1244. u8 device_name[64];
  1245. u8 service_name[64];
  1246. u8 physical_location[64];
  1247. u8 instance_number[4];
  1248. } result;
  1249. spin_lock(&i2o_proc_lock);
  1250. len = 0;
  1251. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  1252. 0xF102, -1,
  1253. &result, sizeof(result));
  1254. if (token < 0) {
  1255. len += i2o_report_query_status(buf+len, token,"0xF102 User Information");
  1256. spin_unlock(&i2o_proc_lock);
  1257. return len;
  1258. }
  1259. len += sprintf(buf,     "Device name     : %sn", chtostr(result.device_name, 64));
  1260. len += sprintf(buf+len, "Service name    : %sn", chtostr(result.service_name, 64));
  1261. len += sprintf(buf+len, "Physical name   : %sn", chtostr(result.physical_location, 64));
  1262. len += sprintf(buf+len, "Instance number : %sn", chtostr(result.instance_number, 4));
  1263. spin_unlock(&i2o_proc_lock);
  1264. return len;
  1265. }
  1266. /* Generic group F103h - SGL Operating Limits (scalar) */
  1267. int i2o_proc_read_sgl_limits(char *buf, char **start, off_t offset, int len, 
  1268.      int *eof, void *data)
  1269. {
  1270. struct i2o_device *d = (struct i2o_device*)data;
  1271. static u32 work32[12];
  1272. static u16 *work16 = (u16 *)work32;
  1273. static u8 *work8 = (u8 *)work32;
  1274. int token;
  1275. spin_lock(&i2o_proc_lock);
  1276. len = 0;
  1277. token = i2o_query_scalar(d->controller, d->lct_data.tid, 
  1278.  0xF103, -1,
  1279.  &work32, sizeof(work32));
  1280. if (token < 0) {
  1281. len += i2o_report_query_status(buf+len, token,"0xF103 SGL Operating Limits");
  1282. spin_unlock(&i2o_proc_lock);
  1283. return len;
  1284. }
  1285. len += sprintf(buf,     "SGL chain size        : %dn", work32[0]);
  1286. len += sprintf(buf+len, "Max SGL chain size    : %dn", work32[1]);
  1287. len += sprintf(buf+len, "SGL chain size target : %dn", work32[2]);
  1288. len += sprintf(buf+len, "SGL frag count        : %dn", work16[6]);
  1289. len += sprintf(buf+len, "Max SGL frag count    : %dn", work16[7]);
  1290. len += sprintf(buf+len, "SGL frag count target : %dn", work16[8]);
  1291. if (d->i2oversion == 0x02)
  1292. {
  1293. len += sprintf(buf+len, "SGL data alignment    : %dn", work16[8]);
  1294. len += sprintf(buf+len, "SGL addr limit        : %dn", work8[20]);
  1295. len += sprintf(buf+len, "SGL addr sizes supported : ");
  1296. if (work8[21] & 0x01)
  1297. len += sprintf(buf+len, "32 bit ");
  1298. if (work8[21] & 0x02)
  1299. len += sprintf(buf+len, "64 bit ");
  1300. if (work8[21] & 0x04)
  1301. len += sprintf(buf+len, "96 bit ");
  1302. if (work8[21] & 0x08)
  1303. len += sprintf(buf+len, "128 bit ");
  1304. len += sprintf(buf+len, "n");
  1305. }
  1306. spin_unlock(&i2o_proc_lock);
  1307. return len;
  1308. }
  1309. /* Generic group F200h - Sensors (scalar) */
  1310. int i2o_proc_read_sensors(char *buf, char **start, off_t offset, int len,
  1311.   int *eof, void *data)
  1312. {
  1313. struct i2o_device *d = (struct i2o_device*)data;
  1314. int token;
  1315. struct
  1316. {
  1317. u16 sensor_instance;
  1318. u8  component;
  1319. u16 component_instance;
  1320. u8  sensor_class;
  1321. u8  sensor_type;
  1322. u8  scaling_exponent;
  1323. u32 actual_reading;
  1324. u32 minimum_reading;
  1325. u32 low2lowcat_treshold;
  1326. u32 lowcat2low_treshold;
  1327. u32 lowwarn2low_treshold;
  1328. u32 low2lowwarn_treshold;
  1329. u32 norm2lowwarn_treshold;
  1330. u32 lowwarn2norm_treshold;
  1331. u32 nominal_reading;
  1332. u32 hiwarn2norm_treshold;
  1333. u32 norm2hiwarn_treshold;
  1334. u32 high2hiwarn_treshold;
  1335. u32 hiwarn2high_treshold;
  1336. u32 hicat2high_treshold;
  1337. u32 hi2hicat_treshold;
  1338. u32 maximum_reading;
  1339. u8  sensor_state;
  1340. u16 event_enable;
  1341. } result;
  1342. spin_lock(&i2o_proc_lock);
  1343. len = 0;
  1344. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  1345.  0xF200, -1,
  1346.  &result, sizeof(result));
  1347. if (token < 0) {
  1348. len += i2o_report_query_status(buf+len, token,"0xF200 Sensors (optional)");
  1349. spin_unlock(&i2o_proc_lock);
  1350. return len;
  1351. }
  1352. len += sprintf(buf+len, "Sensor instance       : %dn", result.sensor_instance);
  1353. len += sprintf(buf+len, "Component             : %d = ", result.component);
  1354. switch (result.component)
  1355. {
  1356. case 0: len += sprintf(buf+len, "Other");
  1357. break;
  1358. case 1: len += sprintf(buf+len, "Planar logic Board");
  1359. break;
  1360. case 2: len += sprintf(buf+len, "CPU");
  1361. break;
  1362. case 3: len += sprintf(buf+len, "Chassis");
  1363. break;
  1364. case 4: len += sprintf(buf+len, "Power Supply");
  1365. break;
  1366. case 5: len += sprintf(buf+len, "Storage");
  1367. break;
  1368. case 6: len += sprintf(buf+len, "External");
  1369. break;
  1370. }
  1371. len += sprintf(buf+len,"n");
  1372. len += sprintf(buf+len, "Component instance    : %dn", result.component_instance);
  1373. len += sprintf(buf+len, "Sensor class          : %sn",
  1374. result.sensor_class ? "Analog" : "Digital");
  1375. len += sprintf(buf+len, "Sensor type           : %d = ",result.sensor_type);
  1376. switch (result.sensor_type)
  1377. {
  1378. case 0: len += sprintf(buf+len, "Othern");
  1379. break;
  1380. case 1: len += sprintf(buf+len, "Thermaln");
  1381. break;
  1382. case 2: len += sprintf(buf+len, "DC voltage (DC volts)n");
  1383. break;
  1384. case 3: len += sprintf(buf+len, "AC voltage (AC volts)n");
  1385. break;
  1386. case 4: len += sprintf(buf+len, "DC current (DC amps)n");
  1387. break;
  1388. case 5: len += sprintf(buf+len, "AC current (AC volts)n");
  1389. break;
  1390. case 6: len += sprintf(buf+len, "Door openn");
  1391. break;
  1392. case 7: len += sprintf(buf+len, "Fan operationaln");
  1393. break;
  1394.   }
  1395. len += sprintf(buf+len, "Scaling exponent      : %dn", result.scaling_exponent);
  1396. len += sprintf(buf+len, "Actual reading        : %dn", result.actual_reading);
  1397. len += sprintf(buf+len, "Minimum reading       : %dn", result.minimum_reading);
  1398. len += sprintf(buf+len, "Low2LowCat treshold   : %dn", result.low2lowcat_treshold);
  1399. len += sprintf(buf+len, "LowCat2Low treshold   : %dn", result.lowcat2low_treshold);
  1400. len += sprintf(buf+len, "LowWarn2Low treshold  : %dn", result.lowwarn2low_treshold);
  1401. len += sprintf(buf+len, "Low2LowWarn treshold  : %dn", result.low2lowwarn_treshold);
  1402. len += sprintf(buf+len, "Norm2LowWarn treshold : %dn", result.norm2lowwarn_treshold);
  1403. len += sprintf(buf+len, "LowWarn2Norm treshold : %dn", result.lowwarn2norm_treshold);
  1404. len += sprintf(buf+len, "Nominal reading       : %dn", result.nominal_reading);
  1405. len += sprintf(buf+len, "HiWarn2Norm treshold  : %dn", result.hiwarn2norm_treshold);
  1406. len += sprintf(buf+len, "Norm2HiWarn treshold  : %dn", result.norm2hiwarn_treshold);
  1407. len += sprintf(buf+len, "High2HiWarn treshold  : %dn", result.high2hiwarn_treshold);
  1408. len += sprintf(buf+len, "HiWarn2High treshold  : %dn", result.hiwarn2high_treshold);
  1409. len += sprintf(buf+len, "HiCat2High treshold   : %dn", result.hicat2high_treshold);
  1410. len += sprintf(buf+len, "High2HiCat treshold   : %dn", result.hi2hicat_treshold);
  1411. len += sprintf(buf+len, "Maximum reading       : %dn", result.maximum_reading);
  1412. len += sprintf(buf+len, "Sensor state          : %d = ", result.sensor_state);
  1413. switch (result.sensor_state)
  1414. {
  1415. case 0:  len += sprintf(buf+len, "Normaln");
  1416.  break;
  1417. case 1:  len += sprintf(buf+len, "Abnormaln");
  1418.  break;
  1419. case 2:  len += sprintf(buf+len, "Unknownn");
  1420.  break;
  1421. case 3:  len += sprintf(buf+len, "Low Catastrophic (LoCat)n");
  1422.  break;
  1423. case 4:  len += sprintf(buf+len, "Low (Low)n");
  1424.  break;
  1425. case 5:  len += sprintf(buf+len, "Low Warning (LoWarn)n");
  1426.  break;
  1427. case 6:  len += sprintf(buf+len, "High Warning (HiWarn)n");
  1428.  break;
  1429. case 7:  len += sprintf(buf+len, "High (High)n");
  1430.  break;
  1431. case 8:  len += sprintf(buf+len, "High Catastrophic (HiCat)n");
  1432.  break;
  1433. }
  1434. len += sprintf(buf+len, "Event_enable : 0x%02Xn", result.event_enable);
  1435. len += sprintf(buf+len, "    [%s] Operational state change. n",
  1436. (result.event_enable & 0x01) ? "+" : "-" );
  1437. len += sprintf(buf+len, "    [%s] Low catastrophic. n",
  1438. (result.event_enable & 0x02) ? "+" : "-" );
  1439. len += sprintf(buf+len, "    [%s] Low reading. n",
  1440. (result.event_enable & 0x04) ? "+" : "-" );
  1441. len += sprintf(buf+len, "    [%s] Low warning. n",
  1442. (result.event_enable & 0x08) ? "+" : "-" );
  1443. len += sprintf(buf+len, "    [%s] Change back to normal from out of range state. n",
  1444. (result.event_enable & 0x10) ? "+" : "-" );
  1445. len += sprintf(buf+len, "    [%s] High warning. n",
  1446. (result.event_enable & 0x20) ? "+" : "-" );
  1447. len += sprintf(buf+len, "    [%s] High reading. n",
  1448. (result.event_enable & 0x40) ? "+" : "-" );
  1449. len += sprintf(buf+len, "    [%s] High catastrophic. n",
  1450. (result.event_enable & 0x80) ? "+" : "-" );
  1451. spin_unlock(&i2o_proc_lock);
  1452. return len;
  1453. }
  1454. static int print_serial_number(char *buff, int pos, u8 *serialno, int max_len)
  1455. {
  1456. int i;
  1457. /* 19990419 -sralston
  1458.  * The I2O v1.5 (and v2.0 so far) "official specification"
  1459.  * got serial numbers WRONG!
  1460.  * Apparently, and despite what Section 3.4.4 says and
  1461.  * Figure 3-35 shows (pg 3-39 in the pdf doc),
  1462.  * the convention / consensus seems to be:
  1463.  *   + First byte is SNFormat
  1464.  *   + Second byte is SNLen (but only if SNFormat==7 (?))
  1465.  *   + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
  1466.  */
  1467. switch(serialno[0])
  1468. {
  1469. case I2O_SNFORMAT_BINARY: /* Binary */
  1470. pos += sprintf(buff+pos, "0x");
  1471. for(i = 0; i < serialno[1]; i++)
  1472. {
  1473. pos += sprintf(buff+pos, "%02X", serialno[2+i]);
  1474. }
  1475. break;
  1476. case I2O_SNFORMAT_ASCII: /* ASCII */
  1477. if ( serialno[1] < ' ' ) /* printable or SNLen? */
  1478. {
  1479. /* sanity */
  1480. max_len = (max_len < serialno[1]) ? max_len : serialno[1];
  1481. serialno[1+max_len] = '';
  1482. /* just print it */
  1483. pos += sprintf(buff+pos, "%s", &serialno[2]);
  1484. }
  1485. else
  1486. {
  1487. /* print chars for specified length */
  1488. for(i = 0; i < serialno[1]; i++)
  1489. {
  1490. pos += sprintf(buff+pos, "%c", serialno[2+i]);
  1491. }
  1492. }
  1493. break;
  1494. case I2O_SNFORMAT_UNICODE: /* UNICODE */
  1495. pos += sprintf(buff+pos, "UNICODE Format.  Can't Displayn");
  1496. break;
  1497. case I2O_SNFORMAT_LAN48_MAC: /* LAN-48 MAC Address */
  1498. pos += sprintf(buff+pos, 
  1499. "LAN-48 MAC address @ %02X:%02X:%02X:%02X:%02X:%02X",
  1500. serialno[2], serialno[3],
  1501. serialno[4], serialno[5],
  1502. serialno[6], serialno[7]);
  1503. break;
  1504. case I2O_SNFORMAT_WAN: /* WAN MAC Address */
  1505. /* FIXME: Figure out what a WAN access address looks like?? */
  1506. pos += sprintf(buff+pos, "WAN Access Address");
  1507. break;
  1508. /* plus new in v2.0 */
  1509. case I2O_SNFORMAT_LAN64_MAC: /* LAN-64 MAC Address */
  1510. /* FIXME: Figure out what a LAN-64 address really looks like?? */
  1511. pos += sprintf(buff+pos, 
  1512. "LAN-64 MAC address @ [?:%02X:%02X:?] %02X:%02X:%02X:%02X:%02X:%02X",
  1513. serialno[8], serialno[9],
  1514. serialno[2], serialno[3],
  1515. serialno[4], serialno[5],
  1516. serialno[6], serialno[7]);
  1517. break;
  1518. case I2O_SNFORMAT_DDM: /* I2O DDM */
  1519. pos += sprintf(buff+pos, 
  1520. "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
  1521. *(u16*)&serialno[2],
  1522. *(u16*)&serialno[4],
  1523. *(u16*)&serialno[6]);
  1524. break;
  1525. case I2O_SNFORMAT_IEEE_REG64: /* IEEE Registered (64-bit) */
  1526. case I2O_SNFORMAT_IEEE_REG128: /* IEEE Registered (128-bit) */
  1527. /* FIXME: Figure if this is even close?? */
  1528. pos += sprintf(buff+pos, 
  1529. "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)n",
  1530. *(u32*)&serialno[2],
  1531. *(u32*)&serialno[6],
  1532. *(u32*)&serialno[10],
  1533. *(u32*)&serialno[14]);
  1534. break;
  1535. case I2O_SNFORMAT_UNKNOWN: /* Unknown 0    */
  1536. case I2O_SNFORMAT_UNKNOWN2: /* Unknown 0xff */
  1537. default:
  1538. pos += sprintf(buff+pos, "Unknown data format (0x%02x)",
  1539.        serialno[0]);
  1540. break;
  1541. }
  1542. return pos;
  1543. }
  1544. const char * i2o_get_connector_type(int conn)
  1545. {
  1546. int idx = 16;
  1547. static char *i2o_connector_type[] = {
  1548. "OTHER",
  1549. "UNKNOWN",
  1550. "AUI",
  1551. "UTP",
  1552. "BNC",
  1553. "RJ45",
  1554. "STP DB9",
  1555. "FIBER MIC",
  1556. "APPLE AUI",
  1557. "MII",
  1558. "DB9",
  1559. "HSSDC",
  1560. "DUPLEX SC FIBER",
  1561. "DUPLEX ST FIBER",
  1562. "TNC/BNC",
  1563. "HW DEFAULT"
  1564. };
  1565. switch(conn)
  1566. {
  1567. case 0x00000000:
  1568. idx = 0;
  1569. break;
  1570. case 0x00000001:
  1571. idx = 1;
  1572. break;
  1573. case 0x00000002:
  1574. idx = 2;
  1575. break;
  1576. case 0x00000003:
  1577. idx = 3;
  1578. break;
  1579. case 0x00000004:
  1580. idx = 4;
  1581. break;
  1582. case 0x00000005:
  1583. idx = 5;
  1584. break;
  1585. case 0x00000006:
  1586. idx = 6;
  1587. break;
  1588. case 0x00000007:
  1589. idx = 7;
  1590. break;
  1591. case 0x00000008:
  1592. idx = 8;
  1593. break;
  1594. case 0x00000009:
  1595. idx = 9;
  1596. break;
  1597. case 0x0000000A:
  1598. idx = 10;
  1599. break;
  1600. case 0x0000000B:
  1601. idx = 11;
  1602. break;
  1603. case 0x0000000C:
  1604. idx = 12;
  1605. break;
  1606. case 0x0000000D:
  1607. idx = 13;
  1608. break;
  1609. case 0x0000000E:
  1610. idx = 14;
  1611. break;
  1612. case 0xFFFFFFFF:
  1613. idx = 15;
  1614. break;
  1615. }
  1616. return i2o_connector_type[idx];
  1617. }
  1618. const char * i2o_get_connection_type(int conn)
  1619. {
  1620. int idx = 0;
  1621. static char *i2o_connection_type[] = {
  1622. "Unknown",
  1623. "AUI",
  1624. "10BASE5",
  1625. "FIORL",
  1626. "10BASE2",
  1627. "10BROAD36",
  1628. "10BASE-T",
  1629. "10BASE-FP",
  1630. "10BASE-FB",
  1631. "10BASE-FL",
  1632. "100BASE-TX",
  1633. "100BASE-FX",
  1634. "100BASE-T4",
  1635. "1000BASE-SX",
  1636. "1000BASE-LX",
  1637. "1000BASE-CX",
  1638. "1000BASE-T",
  1639. "100VG-ETHERNET",
  1640. "100VG-TOKEN RING",
  1641. "4MBIT TOKEN RING",
  1642. "16 Mb Token Ring",
  1643. "125 MBAUD FDDI",
  1644. "Point-to-point",
  1645. "Arbitrated loop",
  1646. "Public loop",
  1647. "Fabric",
  1648. "Emulation",
  1649. "Other",
  1650. "HW default"
  1651. };
  1652. switch(conn)
  1653. {
  1654. case I2O_LAN_UNKNOWN:
  1655. idx = 0;
  1656. break;
  1657. case I2O_LAN_AUI:
  1658. idx = 1;
  1659. break;
  1660. case I2O_LAN_10BASE5:
  1661. idx = 2;
  1662. break;
  1663. case I2O_LAN_FIORL:
  1664. idx = 3;
  1665. break;
  1666. case I2O_LAN_10BASE2:
  1667. idx = 4;
  1668. break;
  1669. case I2O_LAN_10BROAD36:
  1670. idx = 5;
  1671. break;
  1672. case I2O_LAN_10BASE_T:
  1673. idx = 6;
  1674. break;
  1675. case I2O_LAN_10BASE_FP:
  1676. idx = 7;
  1677. break;
  1678. case I2O_LAN_10BASE_FB:
  1679. idx = 8;
  1680. break;
  1681. case I2O_LAN_10BASE_FL:
  1682. idx = 9;
  1683. break;
  1684. case I2O_LAN_100BASE_TX:
  1685. idx = 10;
  1686. break;
  1687. case I2O_LAN_100BASE_FX:
  1688. idx = 11;
  1689. break;
  1690. case I2O_LAN_100BASE_T4:
  1691. idx = 12;
  1692. break;
  1693. case I2O_LAN_1000BASE_SX:
  1694. idx = 13;
  1695. break;
  1696. case I2O_LAN_1000BASE_LX:
  1697. idx = 14;
  1698. break;
  1699. case I2O_LAN_1000BASE_CX:
  1700. idx = 15;
  1701. break;
  1702. case I2O_LAN_1000BASE_T:
  1703. idx = 16;
  1704. break;
  1705. case I2O_LAN_100VG_ETHERNET:
  1706. idx = 17;
  1707. break;
  1708. case I2O_LAN_100VG_TR:
  1709. idx = 18;
  1710. break;
  1711. case I2O_LAN_4MBIT:
  1712. idx = 19;
  1713. break;
  1714. case I2O_LAN_16MBIT:
  1715. idx = 20;
  1716. break;
  1717. case I2O_LAN_125MBAUD:
  1718. idx = 21;
  1719. break;
  1720. case I2O_LAN_POINT_POINT:
  1721. idx = 22;
  1722. break;
  1723. case I2O_LAN_ARB_LOOP:
  1724. idx = 23;
  1725. break;
  1726. case I2O_LAN_PUBLIC_LOOP:
  1727. idx = 24;
  1728. break;
  1729. case I2O_LAN_FABRIC:
  1730. idx = 25;
  1731. break;
  1732. case I2O_LAN_EMULATION:
  1733. idx = 26;
  1734. break;
  1735. case I2O_LAN_OTHER:
  1736. idx = 27;
  1737. break;
  1738. case I2O_LAN_DEFAULT:
  1739. idx = 28;
  1740. break;
  1741. }
  1742. return i2o_connection_type[idx];
  1743. }
  1744. /* LAN group 0000h - Device info (scalar) */
  1745. int i2o_proc_read_lan_dev_info(char *buf, char **start, off_t offset, int len, 
  1746.        int *eof, void *data)
  1747. {
  1748. struct i2o_device *d = (struct i2o_device*)data;
  1749. static u32 work32[56];
  1750. static u8 *work8 = (u8*)work32;
  1751. static u16 *work16 = (u16*)work32;
  1752. static u64 *work64 = (u64*)work32;
  1753. int token;
  1754. spin_lock(&i2o_proc_lock);
  1755. len = 0;
  1756. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  1757.  0x0000, -1, &work32, 56*4);
  1758. if (token < 0) {
  1759. len += i2o_report_query_status(buf+len, token, "0x0000 LAN Device Info");
  1760. spin_unlock(&i2o_proc_lock);
  1761. return len;
  1762. }
  1763. len += sprintf(buf, "LAN Type            : ");
  1764. switch (work16[0])
  1765. {
  1766. case 0x0030:
  1767. len += sprintf(buf+len, "Ethernet, ");
  1768. break;
  1769. case 0x0040:
  1770. len += sprintf(buf+len, "100Base VG, ");
  1771. break;
  1772. case 0x0050:
  1773. len += sprintf(buf+len, "Token Ring, ");
  1774. break;
  1775. case 0x0060:
  1776. len += sprintf(buf+len, "FDDI, ");
  1777. break;
  1778. case 0x0070:
  1779. len += sprintf(buf+len, "Fibre Channel, ");
  1780. break;
  1781. default:
  1782. len += sprintf(buf+len, "Unknown type (0x%04x), ", work16[0]);
  1783. break;
  1784. }
  1785. if (work16[1]&0x00000001)
  1786. len += sprintf(buf+len, "emulated LAN, ");
  1787. else
  1788. len += sprintf(buf+len, "physical LAN port, ");
  1789. if (work16[1]&0x00000002)
  1790. len += sprintf(buf+len, "full duplexn");
  1791. else
  1792. len += sprintf(buf+len, "simplexn");
  1793. len += sprintf(buf+len, "Address format      : ");
  1794. switch(work8[4]) {
  1795. case 0x00:
  1796. len += sprintf(buf+len, "IEEE 48bitn");
  1797. break;
  1798. case 0x01:
  1799. len += sprintf(buf+len, "FC IEEEn");
  1800. break;
  1801. default:
  1802. len += sprintf(buf+len, "Unknown (0x%02x)n", work8[4]);
  1803. break;
  1804. }
  1805. len += sprintf(buf+len, "State               : ");
  1806. switch(work8[5])
  1807. {
  1808. case 0x00:
  1809. len += sprintf(buf+len, "Unknownn");
  1810. break;
  1811. case 0x01:
  1812. len += sprintf(buf+len, "Unclaimedn");
  1813. break;
  1814. case 0x02:
  1815. len += sprintf(buf+len, "Operationaln");
  1816. break;
  1817. case 0x03:
  1818. len += sprintf(buf+len, "Suspendedn");
  1819. break;
  1820. case 0x04:
  1821. len += sprintf(buf+len, "Resettingn");
  1822. break;
  1823. case 0x05:
  1824. len += sprintf(buf+len, "ERROR: ");
  1825. if(work16[3]&0x0001)
  1826. len += sprintf(buf+len, "TxCU inoperative ");
  1827. if(work16[3]&0x0002)
  1828. len += sprintf(buf+len, "RxCU inoperative ");
  1829. if(work16[3]&0x0004)
  1830. len += sprintf(buf+len, "Local mem alloc ");
  1831. len += sprintf(buf+len, "n");
  1832. break;
  1833. case 0x06:
  1834. len += sprintf(buf+len, "Operational no Rxn");
  1835. break;
  1836. case 0x07:
  1837. len += sprintf(buf+len, "Suspended no Rxn");
  1838. break;
  1839. default:
  1840. len += sprintf(buf+len, "Unspecifiedn");
  1841. break;
  1842. }
  1843. len += sprintf(buf+len, "Min packet size     : %dn", work32[2]);
  1844. len += sprintf(buf+len, "Max packet size     : %dn", work32[3]);
  1845. len += sprintf(buf+len, "HW address          : "
  1846.        "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02Xn",
  1847.        work8[16],work8[17],work8[18],work8[19],
  1848.        work8[20],work8[21],work8[22],work8[23]);
  1849. len += sprintf(buf+len, "Max Tx wire speed   : %d bpsn", (int)work64[3]);
  1850. len += sprintf(buf+len, "Max Rx wire speed   : %d bpsn", (int)work64[4]);
  1851. len += sprintf(buf+len, "Min SDU packet size : 0x%08xn", work32[10]);
  1852. len += sprintf(buf+len, "Max SDU packet size : 0x%08xn", work32[11]);
  1853. spin_unlock(&i2o_proc_lock);
  1854. return len;
  1855. }
  1856. /* LAN group 0001h - MAC address table (scalar) */
  1857. int i2o_proc_read_lan_mac_addr(char *buf, char **start, off_t offset, int len, 
  1858.        int *eof, void *data)
  1859. {
  1860. struct i2o_device *d = (struct i2o_device*)data;
  1861. static u32 work32[48];
  1862. static u8 *work8 = (u8*)work32;
  1863. int token;
  1864. spin_lock(&i2o_proc_lock);
  1865. len = 0;
  1866. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  1867.  0x0001, -1, &work32, 48*4);
  1868. if (token < 0) {
  1869. len += i2o_report_query_status(buf+len, token,"0x0001 LAN MAC Address");
  1870. spin_unlock(&i2o_proc_lock);
  1871. return len;
  1872. }
  1873. len += sprintf(buf,     "Active address          : "
  1874.        "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02Xn",
  1875.        work8[0],work8[1],work8[2],work8[3],
  1876.        work8[4],work8[5],work8[6],work8[7]);
  1877. len += sprintf(buf+len, "Current address         : "
  1878.        "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02Xn",
  1879.        work8[8],work8[9],work8[10],work8[11],
  1880.        work8[12],work8[13],work8[14],work8[15]);
  1881. len += sprintf(buf+len, "Functional address mask : "
  1882.        "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02Xn",
  1883.        work8[16],work8[17],work8[18],work8[19],
  1884.        work8[20],work8[21],work8[22],work8[23]);
  1885. len += sprintf(buf+len,"HW/DDM capabilities : 0x%08xn", work32[7]);
  1886. len += sprintf(buf+len,"    [%s] Unicast packets supportedn",
  1887.        (work32[7]&0x00000001)?"+":"-");
  1888. len += sprintf(buf+len,"    [%s] Promiscuous mode supportedn",
  1889.        (work32[7]&0x00000002)?"+":"-");
  1890. len += sprintf(buf+len,"    [%s] Promiscuous multicast mode supportedn",
  1891.        (work32[7]&0x00000004)?"+":"-");
  1892. len += sprintf(buf+len,"    [%s] Broadcast reception disabling supportedn",
  1893.        (work32[7]&0x00000100)?"+":"-");
  1894. len += sprintf(buf+len,"    [%s] Multicast reception disabling supportedn",
  1895.        (work32[7]&0x00000200)?"+":"-");
  1896. len += sprintf(buf+len,"    [%s] Functional address disabling supportedn",
  1897.        (work32[7]&0x00000400)?"+":"-");
  1898. len += sprintf(buf+len,"    [%s] MAC reporting supportedn",
  1899.        (work32[7]&0x00000800)?"+":"-");
  1900. len += sprintf(buf+len,"Filter mask : 0x%08xn", work32[6]);
  1901. len += sprintf(buf+len,"    [%s] Unicast packets disablen",
  1902. (work32[6]&0x00000001)?"+":"-");
  1903. len += sprintf(buf+len,"    [%s] Promiscuous mode enablen",
  1904. (work32[6]&0x00000002)?"+":"-");
  1905. len += sprintf(buf+len,"    [%s] Promiscuous multicast mode enablen",
  1906. (work32[6]&0x00000004)?"+":"-");
  1907. len += sprintf(buf+len,"    [%s] Broadcast packets disablen",
  1908. (work32[6]&0x00000100)?"+":"-");
  1909. len += sprintf(buf+len,"    [%s] Multicast packets disablen",
  1910. (work32[6]&0x00000200)?"+":"-");
  1911. len += sprintf(buf+len,"    [%s] Functional address disablen",
  1912.        (work32[6]&0x00000400)?"+":"-");
  1913.        
  1914. if (work32[7]&0x00000800) {
  1915. len += sprintf(buf+len, "    MAC reporting mode : ");
  1916. if (work32[6]&0x00000800)
  1917. len += sprintf(buf+len, "Pass only priority MAC packets to usern");
  1918. else if (work32[6]&0x00001000)
  1919. len += sprintf(buf+len, "Pass all MAC packets to usern");
  1920. else if (work32[6]&0x00001800)
  1921. len += sprintf(buf+len, "Pass all MAC packets (promiscuous) to usern");
  1922. else
  1923. len += sprintf(buf+len, "Do not pass MAC packets to usern");
  1924. }
  1925. len += sprintf(buf+len, "Number of multicast addresses : %dn", work32[8]);
  1926. len += sprintf(buf+len, "Perfect filtering for max %d multicast addressesn",
  1927.        work32[9]);
  1928. len += sprintf(buf+len, "Imperfect filtering for max %d multicast addressesn",
  1929.        work32[10]);
  1930. spin_unlock(&i2o_proc_lock);
  1931. return len;
  1932. }
  1933. /* LAN group 0002h - Multicast MAC address table (table) */
  1934. int i2o_proc_read_lan_mcast_addr(char *buf, char **start, off_t offset,
  1935.  int len, int *eof, void *data)
  1936. {
  1937. struct i2o_device *d = (struct i2o_device*)data;
  1938. int token;
  1939. int i;
  1940. u8 mc_addr[8];
  1941. struct
  1942. {
  1943. u16 result_count;
  1944. u16 pad;
  1945. u16 block_size;
  1946. u8  block_status;
  1947. u8  error_info_size;
  1948. u16 row_count;
  1949. u16 more_flag;
  1950. u8  mc_addr[256][8];
  1951. } result;
  1952. spin_lock(&i2o_proc_lock);
  1953. len = 0;
  1954. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  1955. d->controller, d->lct_data.tid, 0x0002, -1, 
  1956. NULL, 0, &result, sizeof(result));
  1957. if (token < 0) {
  1958. len += i2o_report_query_status(buf+len, token,"0x002 LAN Multicast MAC Address");
  1959. spin_unlock(&i2o_proc_lock);
  1960. return len;
  1961. }
  1962. for (i = 0; i < result.row_count; i++)
  1963. {
  1964. memcpy(mc_addr, result.mc_addr[i], 8);
  1965. len += sprintf(buf+len, "MC MAC address[%d]: "
  1966.        "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02Xn",
  1967.        i, mc_addr[0], mc_addr[1], mc_addr[2],
  1968.        mc_addr[3], mc_addr[4], mc_addr[5],
  1969.        mc_addr[6], mc_addr[7]);
  1970. }
  1971. spin_unlock(&i2o_proc_lock);
  1972. return len;
  1973. }
  1974. /* LAN group 0003h - Batch Control (scalar) */
  1975. int i2o_proc_read_lan_batch_control(char *buf, char **start, off_t offset,
  1976.     int len, int *eof, void *data)
  1977. {
  1978. struct i2o_device *d = (struct i2o_device*)data;
  1979. static u32 work32[9];
  1980. int token;
  1981. spin_lock(&i2o_proc_lock);
  1982. len = 0;
  1983. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  1984.  0x0003, -1, &work32, 9*4);
  1985. if (token < 0) {
  1986. len += i2o_report_query_status(buf+len, token,"0x0003 LAN Batch Control");
  1987. spin_unlock(&i2o_proc_lock);
  1988. return len;
  1989. }
  1990. len += sprintf(buf, "Batch mode ");
  1991. if (work32[0]&0x00000001)
  1992. len += sprintf(buf+len, "disabled");
  1993. else
  1994. len += sprintf(buf+len, "enabled");
  1995. if (work32[0]&0x00000002)
  1996. len += sprintf(buf+len, " (current setting)");
  1997. if (work32[0]&0x00000004)
  1998. len += sprintf(buf+len, ", forced");
  1999. else
  2000. len += sprintf(buf+len, ", toggle");
  2001. len += sprintf(buf+len, "n");
  2002. len += sprintf(buf+len, "Max Rx batch count : %dn", work32[5]);
  2003. len += sprintf(buf+len, "Max Rx batch delay : %dn", work32[6]);
  2004. len += sprintf(buf+len, "Max Tx batch delay : %dn", work32[7]);
  2005. len += sprintf(buf+len, "Max Tx batch count : %dn", work32[8]);
  2006. spin_unlock(&i2o_proc_lock);
  2007. return len;
  2008. }
  2009. /* LAN group 0004h - LAN Operation (scalar) */
  2010. int i2o_proc_read_lan_operation(char *buf, char **start, off_t offset, int len,
  2011. int *eof, void *data)
  2012. {
  2013. struct i2o_device *d = (struct i2o_device*)data;
  2014. static u32 work32[5];
  2015. int token;
  2016. spin_lock(&i2o_proc_lock);
  2017. len = 0;
  2018. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2019.  0x0004, -1, &work32, 20);
  2020. if (token < 0) {
  2021. len += i2o_report_query_status(buf+len, token,"0x0004 LAN Operation");
  2022. spin_unlock(&i2o_proc_lock);
  2023. return len;
  2024. }
  2025. len += sprintf(buf, "Packet prepadding (32b words) : %dn", work32[0]);
  2026. len += sprintf(buf+len, "Transmission error reporting  : %sn",
  2027.        (work32[1]&1)?"on":"off");
  2028. len += sprintf(buf+len, "Bad packet handling           : %sn",
  2029. (work32[1]&0x2)?"by host":"by DDM");
  2030. len += sprintf(buf+len, "Packet orphan limit           : %dn", work32[2]);
  2031. len += sprintf(buf+len, "Tx modes : 0x%08xn", work32[3]);
  2032. len += sprintf(buf+len, "    [%s] HW CRC suppressionn",
  2033. (work32[3]&0x00000004) ? "+" : "-");
  2034. len += sprintf(buf+len, "    [%s] HW IPv4 checksumn",
  2035. (work32[3]&0x00000100) ? "+" : "-");
  2036. len += sprintf(buf+len, "    [%s] HW TCP checksumn",
  2037. (work32[3]&0x00000200) ? "+" : "-");
  2038. len += sprintf(buf+len, "    [%s] HW UDP checksumn",
  2039. (work32[3]&0x00000400) ? "+" : "-");
  2040. len += sprintf(buf+len, "    [%s] HW RSVP checksumn",
  2041. (work32[3]&0x00000800) ? "+" : "-");
  2042. len += sprintf(buf+len, "    [%s] HW ICMP checksumn",
  2043. (work32[3]&0x00001000) ? "+" : "-");
  2044. len += sprintf(buf+len, "    [%s] Loopback suppression enablen",
  2045. (work32[3]&0x00002000) ? "+" : "-");
  2046. len += sprintf(buf+len, "Rx modes : 0x%08xn", work32[4]);
  2047. len += sprintf(buf+len, "    [%s] FCS in payloadn",
  2048. (work32[4]&0x00000004) ? "+" : "-");
  2049. len += sprintf(buf+len, "    [%s] HW IPv4 checksum validationn",
  2050. (work32[4]&0x00000100) ? "+" : "-");
  2051. len += sprintf(buf+len, "    [%s] HW TCP checksum validationn",
  2052. (work32[4]&0x00000200) ? "+" : "-");
  2053. len += sprintf(buf+len, "    [%s] HW UDP checksum validationn",
  2054. (work32[4]&0x00000400) ? "+" : "-");
  2055. len += sprintf(buf+len, "    [%s] HW RSVP checksum validationn",
  2056. (work32[4]&0x00000800) ? "+" : "-");
  2057. len += sprintf(buf+len, "    [%s] HW ICMP checksum validationn",
  2058. (work32[4]&0x00001000) ? "+" : "-");
  2059.  
  2060. spin_unlock(&i2o_proc_lock);
  2061. return len;
  2062. }
  2063. /* LAN group 0005h - Media operation (scalar) */
  2064. int i2o_proc_read_lan_media_operation(char *buf, char **start, off_t offset,
  2065.       int len, int *eof, void *data)
  2066. {
  2067. struct i2o_device *d = (struct i2o_device*)data;
  2068. int token;
  2069. struct
  2070. {
  2071. u32 connector_type;
  2072. u32 connection_type;
  2073. u64 current_tx_wire_speed;
  2074. u64 current_rx_wire_speed;
  2075. u8  duplex_mode;
  2076. u8  link_status;
  2077. u8  reserved;
  2078. u8  duplex_mode_target;
  2079. u32 connector_type_target;
  2080. u32 connection_type_target;
  2081. } result;
  2082. spin_lock(&i2o_proc_lock);
  2083. len = 0;
  2084. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2085.  0x0005, -1, &result, sizeof(result));
  2086. if (token < 0) {
  2087. len += i2o_report_query_status(buf+len, token, "0x0005 LAN Media Operation");
  2088. spin_unlock(&i2o_proc_lock);
  2089. return len;
  2090. }
  2091. len += sprintf(buf, "Connector type         : %sn",
  2092.        i2o_get_connector_type(result.connector_type));
  2093. len += sprintf(buf+len, "Connection type        : %sn",
  2094.        i2o_get_connection_type(result.connection_type));
  2095. len += sprintf(buf+len, "Current Tx wire speed  : %d bpsn", (int)result.current_tx_wire_speed);
  2096. len += sprintf(buf+len, "Current Rx wire speed  : %d bpsn", (int)result.current_rx_wire_speed);
  2097. len += sprintf(buf+len, "Duplex mode            : %s duplexn",
  2098. (result.duplex_mode)?"Full":"Half");
  2099. len += sprintf(buf+len, "Link status            : ");
  2100. switch (result.link_status)
  2101. {
  2102. case 0x00:
  2103. len += sprintf(buf+len, "Unknownn");
  2104. break;
  2105. case 0x01:
  2106. len += sprintf(buf+len, "Normaln");
  2107. break;
  2108. case 0x02:
  2109. len += sprintf(buf+len, "Failuren");
  2110. break;
  2111. case 0x03:
  2112. len += sprintf(buf+len, "Resetn");
  2113. break;
  2114. default:
  2115. len += sprintf(buf+len, "Unspecifiedn");
  2116. }
  2117. len += sprintf(buf+len, "Duplex mode target     : ");
  2118. switch (result.duplex_mode_target){
  2119. case 0:
  2120. len += sprintf(buf+len, "Half duplexn");
  2121. break;
  2122. case 1:
  2123. len += sprintf(buf+len, "Full duplexn");
  2124. break;
  2125. default:
  2126. len += sprintf(buf+len, "n");
  2127. }
  2128. len += sprintf(buf+len, "Connector type target  : %sn",
  2129.        i2o_get_connector_type(result.connector_type_target));
  2130. len += sprintf(buf+len, "Connection type target : %sn",
  2131.        i2o_get_connection_type(result.connection_type_target));
  2132. spin_unlock(&i2o_proc_lock);
  2133. return len;
  2134. }
  2135. /* LAN group 0006h - Alternate address (table) (optional) */
  2136. int i2o_proc_read_lan_alt_addr(char *buf, char **start, off_t offset, int len,
  2137.        int *eof, void *data)
  2138. {
  2139. struct i2o_device *d = (struct i2o_device*)data;
  2140. int token;
  2141. int i;
  2142. u8 alt_addr[8];
  2143. struct
  2144. {
  2145. u16 result_count;
  2146. u16 pad;
  2147. u16 block_size;
  2148. u8  block_status;
  2149. u8  error_info_size;
  2150. u16 row_count;
  2151. u16 more_flag;
  2152. u8  alt_addr[256][8];
  2153. } result;
  2154. spin_lock(&i2o_proc_lock);
  2155. len = 0;
  2156. token = i2o_query_table(I2O_PARAMS_TABLE_GET,
  2157. d->controller, d->lct_data.tid,
  2158. 0x0006, -1, NULL, 0, &result, sizeof(result));
  2159. if (token < 0) {
  2160. len += i2o_report_query_status(buf+len, token, "0x0006 LAN Alternate Address (optional)");
  2161. spin_unlock(&i2o_proc_lock);
  2162. return len;
  2163. }
  2164. for (i=0; i < result.row_count; i++)
  2165. {
  2166. memcpy(alt_addr,result.alt_addr[i],8);
  2167. len += sprintf(buf+len, "Alternate address[%d]: "
  2168.        "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02Xn",
  2169.        i, alt_addr[0], alt_addr[1], alt_addr[2],
  2170.        alt_addr[3], alt_addr[4], alt_addr[5],
  2171.        alt_addr[6], alt_addr[7]);
  2172. }
  2173. spin_unlock(&i2o_proc_lock);
  2174. return len;
  2175. }
  2176. /* LAN group 0007h - Transmit info (scalar) */
  2177. int i2o_proc_read_lan_tx_info(char *buf, char **start, off_t offset, int len, 
  2178.       int *eof, void *data)
  2179. {
  2180. struct i2o_device *d = (struct i2o_device*)data;
  2181. static u32 work32[8];
  2182. int token;
  2183. spin_lock(&i2o_proc_lock);
  2184. len = 0;
  2185. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2186.  0x0007, -1, &work32, 8*4);
  2187. if (token < 0) {
  2188. len += i2o_report_query_status(buf+len, token,"0x0007 LAN Transmit Info");
  2189. spin_unlock(&i2o_proc_lock);
  2190. return len;
  2191. }
  2192. len += sprintf(buf,     "Tx Max SG elements per packet : %dn", work32[0]);
  2193. len += sprintf(buf+len, "Tx Max SG elements per chain  : %dn", work32[1]);
  2194. len += sprintf(buf+len, "Tx Max outstanding packets    : %dn", work32[2]);
  2195. len += sprintf(buf+len, "Tx Max packets per request    : %dn", work32[3]);
  2196. len += sprintf(buf+len, "Tx modes : 0x%08xn", work32[4]);
  2197. len += sprintf(buf+len, "    [%s] No DA in SGLn",
  2198. (work32[4]&0x00000002) ? "+" : "-");
  2199. len += sprintf(buf+len, "    [%s] CRC suppressionn",
  2200. (work32[4]&0x00000004) ? "+" : "-");
  2201. len += sprintf(buf+len, "    [%s] MAC insertionn",
  2202. (work32[4]&0x00000010) ? "+" : "-");
  2203. len += sprintf(buf+len, "    [%s] RIF insertionn",
  2204. (work32[4]&0x00000020) ? "+" : "-");
  2205. len += sprintf(buf+len, "    [%s] IPv4 checksum generationn",
  2206. (work32[4]&0x00000100) ? "+" : "-");
  2207. len += sprintf(buf+len, "    [%s] TCP checksum generationn",
  2208. (work32[4]&0x00000200) ? "+" : "-");
  2209. len += sprintf(buf+len, "    [%s] UDP checksum generationn",
  2210. (work32[4]&0x00000400) ? "+" : "-");
  2211. len += sprintf(buf+len, "    [%s] RSVP checksum generationn",
  2212. (work32[4]&0x00000800) ? "+" : "-");
  2213. len += sprintf(buf+len, "    [%s] ICMP checksum generationn",
  2214. (work32[4]&0x00001000) ? "+" : "-");
  2215. len += sprintf(buf+len, "    [%s] Loopback enabledn",
  2216. (work32[4]&0x00010000) ? "+" : "-");
  2217. len += sprintf(buf+len, "    [%s] Loopback suppression enabledn",
  2218. (work32[4]&0x00020000) ? "+" : "-");
  2219. spin_unlock(&i2o_proc_lock);
  2220. return len;
  2221. }
  2222. /* LAN group 0008h - Receive info (scalar) */
  2223. int i2o_proc_read_lan_rx_info(char *buf, char **start, off_t offset, int len, 
  2224.       int *eof, void *data)
  2225. {
  2226. struct i2o_device *d = (struct i2o_device*)data;
  2227. static u32 work32[8];
  2228. int token;
  2229. spin_lock(&i2o_proc_lock);
  2230. len = 0;
  2231. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2232.  0x0008, -1, &work32, 8*4);
  2233. if (token < 0) {
  2234. len += i2o_report_query_status(buf+len, token,"0x0008 LAN Receive Info");
  2235. spin_unlock(&i2o_proc_lock);
  2236. return len;
  2237. }
  2238. len += sprintf(buf     ,"Rx Max size of chain element : %dn", work32[0]);
  2239. len += sprintf(buf+len, "Rx Max Buckets               : %dn", work32[1]);
  2240. len += sprintf(buf+len, "Rx Max Buckets in Reply      : %dn", work32[3]);
  2241. len += sprintf(buf+len, "Rx Max Packets in Bucket     : %dn", work32[4]);
  2242. len += sprintf(buf+len, "Rx Max Buckets in Post       : %dn", work32[5]);
  2243. len += sprintf(buf+len, "Rx Modes : 0x%08xn", work32[2]);
  2244. len += sprintf(buf+len, "    [%s] FCS receptionn",
  2245. (work32[2]&0x00000004) ? "+" : "-");
  2246. len += sprintf(buf+len, "    [%s] IPv4 checksum validation n",
  2247. (work32[2]&0x00000100) ? "+" : "-");
  2248. len += sprintf(buf+len, "    [%s] TCP checksum validation n",
  2249. (work32[2]&0x00000200) ? "+" : "-");
  2250. len += sprintf(buf+len, "    [%s] UDP checksum validation n",
  2251. (work32[2]&0x00000400) ? "+" : "-");
  2252. len += sprintf(buf+len, "    [%s] RSVP checksum validation n",
  2253. (work32[2]&0x00000800) ? "+" : "-");
  2254. len += sprintf(buf+len, "    [%s] ICMP checksum validation n",
  2255. (work32[2]&0x00001000) ? "+" : "-");
  2256. spin_unlock(&i2o_proc_lock);
  2257. return len;
  2258. }
  2259. static int i2o_report_opt_field(char *buf, char *field_name,
  2260. int field_nbr, int supp_fields, u64 *value)
  2261. {
  2262. if (supp_fields & (1 << field_nbr))
  2263. return sprintf(buf, "%-24s : " FMT_U64_HEX "n", field_name, U64_VAL(value));
  2264. else
  2265. return sprintf(buf, "%-24s : Not supportedn", field_name);
  2266. }
  2267. /* LAN group 0100h - LAN Historical statistics (scalar) */
  2268. /* LAN group 0180h - Supported Optional Historical Statistics (scalar) */
  2269. /* LAN group 0182h - Optional Non Media Specific Transmit Historical Statistics (scalar) */
  2270. /* LAN group 0183h - Optional Non Media Specific Receive Historical Statistics (scalar) */
  2271. int i2o_proc_read_lan_hist_stats(char *buf, char **start, off_t offset, int len,
  2272.  int *eof, void *data)
  2273. {
  2274. struct i2o_device *d = (struct i2o_device*)data;
  2275. int token;
  2276. struct
  2277. {
  2278. u64 tx_packets;
  2279. u64 tx_bytes;
  2280. u64 rx_packets;
  2281. u64 rx_bytes;
  2282. u64 tx_errors;
  2283. u64 rx_errors;
  2284. u64 rx_dropped;
  2285. u64 adapter_resets;
  2286. u64 adapter_suspends;
  2287. } stats; // 0x0100
  2288. static u64 supp_groups[4]; // 0x0180
  2289. struct
  2290. {
  2291. u64 tx_retries;
  2292. u64 tx_directed_bytes;
  2293. u64 tx_directed_packets;
  2294. u64 tx_multicast_bytes;
  2295. u64 tx_multicast_packets;
  2296. u64 tx_broadcast_bytes;
  2297. u64 tx_broadcast_packets;
  2298. u64 tx_group_addr_packets;
  2299. u64 tx_short_packets;
  2300. } tx_stats; // 0x0182
  2301. struct
  2302. {
  2303. u64 rx_crc_errors;
  2304. u64 rx_directed_bytes;
  2305. u64 rx_directed_packets;
  2306. u64 rx_multicast_bytes;
  2307. u64 rx_multicast_packets;
  2308. u64 rx_broadcast_bytes;
  2309. u64 rx_broadcast_packets;
  2310. u64 rx_group_addr_packets;
  2311. u64 rx_short_packets;
  2312. u64 rx_long_packets;
  2313. u64 rx_runt_packets;
  2314. } rx_stats; // 0x0183
  2315. struct
  2316. {
  2317. u64 ipv4_generate;
  2318. u64 ipv4_validate_success;
  2319. u64 ipv4_validate_errors;
  2320. u64 tcp_generate;
  2321. u64 tcp_validate_success;
  2322. u64 tcp_validate_errors;
  2323. u64 udp_generate;
  2324. u64 udp_validate_success;
  2325. u64 udp_validate_errors;
  2326. u64 rsvp_generate;
  2327. u64 rsvp_validate_success;
  2328. u64 rsvp_validate_errors;
  2329. u64 icmp_generate;
  2330. u64 icmp_validate_success;
  2331. u64 icmp_validate_errors;
  2332. } chksum_stats; // 0x0184
  2333. spin_lock(&i2o_proc_lock);
  2334. len = 0;
  2335. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2336.  0x0100, -1, &stats, sizeof(stats));
  2337. if (token < 0) {
  2338. len += i2o_report_query_status(buf+len, token,"0x100 LAN Statistics");
  2339. spin_unlock(&i2o_proc_lock);
  2340. return len;
  2341. }
  2342. len += sprintf(buf+len, "Tx packets       : " FMT_U64_HEX "n",
  2343.        U64_VAL(&stats.tx_packets));
  2344. len += sprintf(buf+len, "Tx bytes         : " FMT_U64_HEX "n",
  2345.        U64_VAL(&stats.tx_bytes));
  2346. len += sprintf(buf+len, "Rx packets       : " FMT_U64_HEX "n",
  2347.        U64_VAL(&stats.rx_packets));
  2348. len += sprintf(buf+len, "Rx bytes         : " FMT_U64_HEX "n",
  2349.        U64_VAL(&stats.rx_bytes));
  2350. len += sprintf(buf+len, "Tx errors        : " FMT_U64_HEX "n",
  2351.        U64_VAL(&stats.tx_errors));
  2352. len += sprintf(buf+len, "Rx errors        : " FMT_U64_HEX "n",
  2353.        U64_VAL(&stats.rx_errors));
  2354. len += sprintf(buf+len, "Rx dropped       : " FMT_U64_HEX "n",
  2355.        U64_VAL(&stats.rx_dropped));
  2356. len += sprintf(buf+len, "Adapter resets   : " FMT_U64_HEX "n",
  2357.        U64_VAL(&stats.adapter_resets));
  2358. len += sprintf(buf+len, "Adapter suspends : " FMT_U64_HEX "n",
  2359.        U64_VAL(&stats.adapter_suspends));
  2360. /* Optional statistics follows */
  2361. /* Get 0x0180 to see which optional groups/fields are supported */
  2362. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2363.  0x0180, -1, &supp_groups, sizeof(supp_groups));
  2364. if (token < 0) {
  2365. len += i2o_report_query_status(buf+len, token, "0x180 LAN Supported Optional Statistics");
  2366. spin_unlock(&i2o_proc_lock);
  2367. return len;
  2368. }
  2369. if (supp_groups[1]) /* 0x0182 */
  2370. {
  2371. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2372.   0x0182, -1, &tx_stats, sizeof(tx_stats));
  2373. if (token < 0) {
  2374. len += i2o_report_query_status(buf+len, token,"0x182 LAN Optional Tx Historical Statistics");
  2375. spin_unlock(&i2o_proc_lock);
  2376. return len;
  2377. }
  2378. len += sprintf(buf+len, "==== Optional TX statistics (group 0182h)n");
  2379. len += i2o_report_opt_field(buf+len, "Tx RetryCount",
  2380. 0, supp_groups[1], &tx_stats.tx_retries);
  2381. len += i2o_report_opt_field(buf+len, "Tx DirectedBytes",
  2382. 1, supp_groups[1], &tx_stats.tx_directed_bytes);
  2383. len += i2o_report_opt_field(buf+len, "Tx DirectedPackets",
  2384. 2, supp_groups[1], &tx_stats.tx_directed_packets);
  2385. len += i2o_report_opt_field(buf+len, "Tx MulticastBytes",
  2386. 3, supp_groups[1], &tx_stats.tx_multicast_bytes);
  2387. len += i2o_report_opt_field(buf+len, "Tx MulticastPackets",
  2388. 4, supp_groups[1], &tx_stats.tx_multicast_packets);
  2389. len += i2o_report_opt_field(buf+len, "Tx BroadcastBytes",
  2390. 5, supp_groups[1], &tx_stats.tx_broadcast_bytes);
  2391. len += i2o_report_opt_field(buf+len, "Tx BroadcastPackets",
  2392. 6, supp_groups[1], &tx_stats.tx_broadcast_packets);
  2393. len += i2o_report_opt_field(buf+len, "Tx TotalGroupAddrPackets",
  2394. 7, supp_groups[1], &tx_stats.tx_group_addr_packets);
  2395. len += i2o_report_opt_field(buf+len, "Tx TotalPacketsTooShort",
  2396. 8, supp_groups[1], &tx_stats.tx_short_packets);
  2397. }
  2398. if (supp_groups[2]) /* 0x0183 */
  2399. {
  2400. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2401.  0x0183, -1, &rx_stats, sizeof(rx_stats));
  2402. if (token < 0) {
  2403. len += i2o_report_query_status(buf+len, token,"0x183 LAN Optional Rx Historical Stats");
  2404. spin_unlock(&i2o_proc_lock);
  2405. return len;
  2406. }
  2407. len += sprintf(buf+len, "==== Optional RX statistics (group 0183h)n");
  2408. len += i2o_report_opt_field(buf+len, "Rx CRCErrorCount",
  2409. 0, supp_groups[2], &rx_stats.rx_crc_errors);
  2410. len += i2o_report_opt_field(buf+len, "Rx DirectedBytes",
  2411. 1, supp_groups[2], &rx_stats.rx_directed_bytes);
  2412. len += i2o_report_opt_field(buf+len, "Rx DirectedPackets",
  2413. 2, supp_groups[2], &rx_stats.rx_directed_packets);
  2414. len += i2o_report_opt_field(buf+len, "Rx MulticastBytes",
  2415. 3, supp_groups[2], &rx_stats.rx_multicast_bytes);
  2416. len += i2o_report_opt_field(buf+len, "Rx MulticastPackets",
  2417. 4, supp_groups[2], &rx_stats.rx_multicast_packets);
  2418. len += i2o_report_opt_field(buf+len, "Rx BroadcastBytes",
  2419. 5, supp_groups[2], &rx_stats.rx_broadcast_bytes);
  2420. len += i2o_report_opt_field(buf+len, "Rx BroadcastPackets",
  2421. 6, supp_groups[2], &rx_stats.rx_broadcast_packets);
  2422. len += i2o_report_opt_field(buf+len, "Rx TotalGroupAddrPackets",
  2423. 7, supp_groups[2], &rx_stats.rx_group_addr_packets);
  2424. len += i2o_report_opt_field(buf+len, "Rx TotalPacketsTooShort",
  2425. 8, supp_groups[2], &rx_stats.rx_short_packets);
  2426. len += i2o_report_opt_field(buf+len, "Rx TotalPacketsTooLong",
  2427. 9, supp_groups[2], &rx_stats.rx_long_packets);
  2428. len += i2o_report_opt_field(buf+len, "Rx TotalPacketsRunt",
  2429. 10, supp_groups[2], &rx_stats.rx_runt_packets);
  2430. }
  2431. if (supp_groups[3]) /* 0x0184 */
  2432. {
  2433. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2434.   0x0184, -1, &chksum_stats, sizeof(chksum_stats));
  2435. if (token < 0) {
  2436. len += i2o_report_query_status(buf+len, token,"0x184 LAN Optional Chksum Historical Stats");
  2437. spin_unlock(&i2o_proc_lock);
  2438. return len;
  2439. }
  2440. len += sprintf(buf+len, "==== Optional CHKSUM statistics (group 0x0184)n");
  2441. len += i2o_report_opt_field(buf+len, "IPv4 Generate",
  2442. 0, supp_groups[3], &chksum_stats.ipv4_generate);
  2443. len += i2o_report_opt_field(buf+len, "IPv4 ValidateSuccess",
  2444. 1, supp_groups[3], &chksum_stats.ipv4_validate_success);
  2445. len += i2o_report_opt_field(buf+len, "IPv4 ValidateError",
  2446. 2, supp_groups[3], &chksum_stats.ipv4_validate_errors);
  2447. len += i2o_report_opt_field(buf+len, "TCP  Generate",
  2448. 3, supp_groups[3], &chksum_stats.tcp_generate);
  2449. len += i2o_report_opt_field(buf+len, "TCP  ValidateSuccess",
  2450. 4, supp_groups[3], &chksum_stats.tcp_validate_success);
  2451. len += i2o_report_opt_field(buf+len, "TCP  ValidateError",
  2452. 5, supp_groups[3], &chksum_stats.tcp_validate_errors);
  2453. len += i2o_report_opt_field(buf+len, "UDP  Generate",
  2454. 6, supp_groups[3], &chksum_stats.udp_generate);
  2455. len += i2o_report_opt_field(buf+len, "UDP  ValidateSuccess",
  2456. 7, supp_groups[3], &chksum_stats.udp_validate_success);
  2457. len += i2o_report_opt_field(buf+len, "UDP  ValidateError",
  2458. 8, supp_groups[3], &chksum_stats.udp_validate_errors);
  2459. len += i2o_report_opt_field(buf+len, "RSVP Generate",
  2460. 9, supp_groups[3], &chksum_stats.rsvp_generate);
  2461. len += i2o_report_opt_field(buf+len, "RSVP ValidateSuccess",
  2462. 10, supp_groups[3], &chksum_stats.rsvp_validate_success);
  2463. len += i2o_report_opt_field(buf+len, "RSVP ValidateError",
  2464. 11, supp_groups[3], &chksum_stats.rsvp_validate_errors);
  2465. len += i2o_report_opt_field(buf+len, "ICMP Generate",
  2466. 12, supp_groups[3], &chksum_stats.icmp_generate);
  2467. len += i2o_report_opt_field(buf+len, "ICMP ValidateSuccess",
  2468. 13, supp_groups[3], &chksum_stats.icmp_validate_success);
  2469. len += i2o_report_opt_field(buf+len, "ICMP ValidateError",
  2470. 14, supp_groups[3], &chksum_stats.icmp_validate_errors);
  2471. }
  2472. spin_unlock(&i2o_proc_lock);
  2473. return len;
  2474. }
  2475. /* LAN group 0200h - Required Ethernet Statistics (scalar) */
  2476. /* LAN group 0280h - Optional Ethernet Statistics Supported (scalar) */
  2477. /* LAN group 0281h - Optional Ethernet Historical Statistics (scalar) */
  2478. int i2o_proc_read_lan_eth_stats(char *buf, char **start, off_t offset,
  2479. int len, int *eof, void *data)
  2480. {
  2481. struct i2o_device *d = (struct i2o_device*)data;
  2482. int token;
  2483. struct
  2484. {
  2485. u64 rx_align_errors;
  2486. u64 tx_one_collisions;
  2487. u64 tx_multiple_collisions;
  2488. u64 tx_deferred;
  2489. u64 tx_late_collisions;
  2490. u64 tx_max_collisions;
  2491. u64 tx_carrier_lost;
  2492. u64 tx_excessive_deferrals;
  2493. } stats;
  2494. static u64 supp_fields;
  2495. struct
  2496. {
  2497. u64 rx_overrun;
  2498. u64 tx_underrun;
  2499. u64 tx_heartbeat_failure;
  2500. } hist_stats;
  2501. spin_lock(&i2o_proc_lock);
  2502. len = 0;
  2503. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2504.  0x0200, -1, &stats, sizeof(stats));
  2505. if (token < 0) {
  2506. len += i2o_report_query_status(buf+len, token,"0x0200 LAN Ethernet Statistics");
  2507. spin_unlock(&i2o_proc_lock);
  2508. return len;
  2509. }
  2510. len += sprintf(buf+len, "Rx alignment errors    : " FMT_U64_HEX "n",
  2511.        U64_VAL(&stats.rx_align_errors));
  2512. len += sprintf(buf+len, "Tx one collisions      : " FMT_U64_HEX "n",
  2513.        U64_VAL(&stats.tx_one_collisions));
  2514. len += sprintf(buf+len, "Tx multicollisions     : " FMT_U64_HEX "n",
  2515.        U64_VAL(&stats.tx_multiple_collisions));
  2516. len += sprintf(buf+len, "Tx deferred            : " FMT_U64_HEX "n",
  2517.        U64_VAL(&stats.tx_deferred));
  2518. len += sprintf(buf+len, "Tx late collisions     : " FMT_U64_HEX "n",
  2519.        U64_VAL(&stats.tx_late_collisions));
  2520. len += sprintf(buf+len, "Tx max collisions      : " FMT_U64_HEX "n",
  2521.        U64_VAL(&stats.tx_max_collisions));
  2522. len += sprintf(buf+len, "Tx carrier lost        : " FMT_U64_HEX "n",
  2523.        U64_VAL(&stats.tx_carrier_lost));
  2524. len += sprintf(buf+len, "Tx excessive deferrals : " FMT_U64_HEX "n",
  2525.        U64_VAL(&stats.tx_excessive_deferrals));
  2526. /* Optional Ethernet statistics follows  */
  2527. /* Get 0x0280 to see which optional fields are supported */
  2528. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2529.  0x0280, -1, &supp_fields, sizeof(supp_fields));
  2530. if (token < 0) {
  2531. len += i2o_report_query_status(buf+len, token,"0x0280 LAN Supported Optional Ethernet Statistics");
  2532. spin_unlock(&i2o_proc_lock);
  2533. return len;
  2534. }
  2535. if (supp_fields) /* 0x0281 */
  2536. {
  2537. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2538.  0x0281, -1, &stats, sizeof(stats));
  2539. if (token < 0) {
  2540. len += i2o_report_query_status(buf+len, token,"0x0281 LAN Optional Ethernet Statistics");
  2541. spin_unlock(&i2o_proc_lock);
  2542. return len;
  2543. }
  2544. len += sprintf(buf+len, "==== Optional ETHERNET statistics (group 0x0281)n");
  2545. len += i2o_report_opt_field(buf+len, "Rx Overrun",
  2546. 0, supp_fields, &hist_stats.rx_overrun);
  2547. len += i2o_report_opt_field(buf+len, "Tx Underrun",
  2548. 1, supp_fields, &hist_stats.tx_underrun);
  2549. len += i2o_report_opt_field(buf+len, "Tx HeartbeatFailure",
  2550. 2, supp_fields, &hist_stats.tx_heartbeat_failure);
  2551. }
  2552. spin_unlock(&i2o_proc_lock);
  2553. return len;
  2554. }
  2555. /* LAN group 0300h - Required Token Ring Statistics (scalar) */
  2556. /* LAN group 0380h, 0381h - Optional Statistics not yet defined (TODO) */
  2557. int i2o_proc_read_lan_tr_stats(char *buf, char **start, off_t offset,
  2558.        int len, int *eof, void *data)
  2559. {
  2560. struct i2o_device *d = (struct i2o_device*)data;
  2561. static u64 work64[13];
  2562. int token;
  2563. static char *ring_status[] =
  2564. {
  2565. "",
  2566. "",
  2567. "",
  2568. "",
  2569. "",
  2570. "Ring Recovery",
  2571. "Single Station",
  2572. "Counter Overflow",
  2573. "Remove Received",
  2574. "",
  2575. "Auto-Removal Error 1",
  2576. "Lobe Wire Fault",
  2577. "Transmit Beacon",
  2578. "Soft Error",
  2579. "Hard Error",
  2580. "Signal Loss"
  2581. };
  2582. spin_lock(&i2o_proc_lock);
  2583. len = 0;
  2584. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2585.  0x0300, -1, &work64, sizeof(work64));
  2586. if (token < 0) {
  2587. len += i2o_report_query_status(buf+len, token,"0x0300 Token Ring Statistics");
  2588. spin_unlock(&i2o_proc_lock);
  2589. return len;
  2590. }
  2591. len += sprintf(buf,     "LineErrors          : " FMT_U64_HEX "n",
  2592.        U64_VAL(&work64[0]));
  2593. len += sprintf(buf+len, "LostFrames          : " FMT_U64_HEX "n",
  2594.        U64_VAL(&work64[1]));
  2595. len += sprintf(buf+len, "ACError             : " FMT_U64_HEX "n",
  2596.        U64_VAL(&work64[2]));
  2597. len += sprintf(buf+len, "TxAbortDelimiter    : " FMT_U64_HEX "n",
  2598.        U64_VAL(&work64[3]));
  2599. len += sprintf(buf+len, "BursErrors          : " FMT_U64_HEX "n",
  2600.        U64_VAL(&work64[4]));
  2601. len += sprintf(buf+len, "FrameCopiedErrors   : " FMT_U64_HEX "n",
  2602.        U64_VAL(&work64[5]));
  2603. len += sprintf(buf+len, "FrequencyErrors     : " FMT_U64_HEX "n",
  2604.        U64_VAL(&work64[6]));
  2605. len += sprintf(buf+len, "InternalErrors      : " FMT_U64_HEX "n",
  2606.        U64_VAL(&work64[7]));
  2607. len += sprintf(buf+len, "LastRingStatus      : %sn", ring_status[work64[8]]);
  2608. len += sprintf(buf+len, "TokenError          : " FMT_U64_HEX "n",
  2609.        U64_VAL(&work64[9]));
  2610. len += sprintf(buf+len, "UpstreamNodeAddress : " FMT_U64_HEX "n",
  2611.        U64_VAL(&work64[10]));
  2612. len += sprintf(buf+len, "LastRingID          : " FMT_U64_HEX "n",
  2613.        U64_VAL(&work64[11]));
  2614. len += sprintf(buf+len, "LastBeaconType      : " FMT_U64_HEX "n",
  2615.        U64_VAL(&work64[12]));
  2616. spin_unlock(&i2o_proc_lock);
  2617. return len;
  2618. }
  2619. /* LAN group 0400h - Required FDDI Statistics (scalar) */
  2620. /* LAN group 0480h, 0481h - Optional Statistics, not yet defined (TODO) */
  2621. int i2o_proc_read_lan_fddi_stats(char *buf, char **start, off_t offset,
  2622.  int len, int *eof, void *data)
  2623. {
  2624. struct i2o_device *d = (struct i2o_device*)data;
  2625. static u64 work64[11];
  2626. int token;
  2627. static char *conf_state[] =
  2628. {
  2629. "Isolated",
  2630. "Local a",
  2631. "Local b",
  2632. "Local ab",
  2633. "Local s",
  2634. "Wrap a",
  2635. "Wrap b",
  2636. "Wrap ab",
  2637. "Wrap s",
  2638. "C-Wrap a",
  2639. "C-Wrap b",
  2640. "C-Wrap s",
  2641. "Through",
  2642. };
  2643. static char *ring_state[] =
  2644. {
  2645. "Isolated",
  2646. "Non-op",
  2647. "Rind-op",
  2648. "Detect",
  2649. "Non-op-Dup",
  2650. "Ring-op-Dup",
  2651. "Directed",
  2652. "Trace"
  2653. };
  2654. static char *link_state[] =
  2655. {
  2656. "Off",
  2657. "Break",
  2658. "Trace",
  2659. "Connect",
  2660. "Next",
  2661. "Signal",
  2662. "Join",
  2663. "Verify",
  2664. "Active",
  2665. "Maintenance"
  2666. };
  2667. spin_lock(&i2o_proc_lock);
  2668. len = 0;
  2669. token = i2o_query_scalar(d->controller, d->lct_data.tid,
  2670.  0x0400, -1, &work64, sizeof(work64));
  2671. if (token < 0) {
  2672. len += i2o_report_query_status(buf+len, token,"0x0400 FDDI Required Statistics");
  2673. spin_unlock(&i2o_proc_lock);
  2674. return len;
  2675. }
  2676. len += sprintf(buf+len, "ConfigurationState : %sn", conf_state[work64[0]]);
  2677. len += sprintf(buf+len, "UpstreamNode       : " FMT_U64_HEX "n",
  2678.        U64_VAL(&work64[1]));
  2679. len += sprintf(buf+len, "DownStreamNode     : " FMT_U64_HEX "n",
  2680.        U64_VAL(&work64[2]));
  2681. len += sprintf(buf+len, "FrameErrors        : " FMT_U64_HEX "n",
  2682.        U64_VAL(&work64[3]));
  2683. len += sprintf(buf+len, "FramesLost         : " FMT_U64_HEX "n",
  2684.        U64_VAL(&work64[4]));
  2685. len += sprintf(buf+len, "RingMgmtState      : %sn", ring_state[work64[5]]);
  2686. len += sprintf(buf+len, "LCTFailures        : " FMT_U64_HEX "n",
  2687.        U64_VAL(&work64[6]));
  2688. len += sprintf(buf+len, "LEMRejects         : " FMT_U64_HEX "n",
  2689.        U64_VAL(&work64[7]));
  2690. len += sprintf(buf+len, "LEMCount           : " FMT_U64_HEX "n",
  2691.        U64_VAL(&work64[8]));
  2692. len += sprintf(buf+len, "LConnectionState   : %sn",
  2693.        link_state[work64[9]]);
  2694. spin_unlock(&i2o_proc_lock);
  2695. return len;
  2696. }
  2697. static int i2o_proc_create_entries(void *data, i2o_proc_entry *pentry,
  2698.    struct proc_dir_entry *parent)
  2699. {
  2700. struct proc_dir_entry *ent;
  2701. while(pentry->name != NULL)
  2702. {
  2703. ent = create_proc_entry(pentry->name, pentry->mode, parent);
  2704. if(!ent) return -1;
  2705. ent->data = data;
  2706. ent->read_proc = pentry->read_proc;
  2707. ent->write_proc = pentry->write_proc;
  2708. ent->nlink = 1;
  2709. pentry++;
  2710. }
  2711. return 0;
  2712. }
  2713. static void i2o_proc_remove_entries(i2o_proc_entry *pentry, 
  2714.     struct proc_dir_entry *parent)
  2715. {
  2716. while(pentry->name != NULL)
  2717. {
  2718. remove_proc_entry(pentry->name, parent);
  2719. pentry++;
  2720. }
  2721. }
  2722. static int i2o_proc_add_controller(struct i2o_controller *pctrl, 
  2723.    struct proc_dir_entry *root )
  2724. {
  2725. struct proc_dir_entry *dir, *dir1;
  2726. struct i2o_device *dev;
  2727. char buff[10];
  2728. sprintf(buff, "iop%d", pctrl->unit);
  2729. dir = proc_mkdir(buff, root);
  2730. if(!dir)
  2731. return -1;
  2732. pctrl->proc_entry = dir;
  2733. i2o_proc_create_entries(pctrl, generic_iop_entries, dir);
  2734. for(dev = pctrl->devices; dev; dev = dev->next)
  2735. {
  2736. sprintf(buff, "%0#5x", dev->lct_data.tid);
  2737. dir1 = proc_mkdir(buff, dir);
  2738. dev->proc_entry = dir1;
  2739. if(!dir1)
  2740. printk(KERN_INFO "i2o_proc: Could not allocate proc dirn");
  2741. i2o_proc_add_device(dev, dir1);
  2742. }
  2743. return 0;
  2744. }
  2745. void i2o_proc_new_dev(struct i2o_controller *c, struct i2o_device *d)
  2746. {
  2747. char buff[10];
  2748. #ifdef DRIVERDEBUG
  2749. printk(KERN_INFO "Adding new device to /proc/i2o/iop%dn", c->unit);
  2750. #endif
  2751. sprintf(buff, "%0#5x", d->lct_data.tid);
  2752. d->proc_entry = proc_mkdir(buff, c->proc_entry);
  2753. if(!d->proc_entry)
  2754. {
  2755. printk(KERN_WARNING "i2o: Could not allocate procdir!n");
  2756. return;
  2757. }
  2758. i2o_proc_add_device(d, d->proc_entry);
  2759. }
  2760. void i2o_proc_add_device(struct i2o_device *dev, struct proc_dir_entry *dir)
  2761. {
  2762. i2o_proc_create_entries(dev, generic_dev_entries, dir);
  2763. /* Inform core that we want updates about this device's status */
  2764. i2o_device_notify_on(dev, &i2o_proc_handler);
  2765. switch(dev->lct_data.class_id)
  2766. {
  2767. case I2O_CLASS_SCSI_PERIPHERAL:
  2768. case I2O_CLASS_RANDOM_BLOCK_STORAGE:
  2769. i2o_proc_create_entries(dev, rbs_dev_entries, dir);
  2770. break;
  2771. case I2O_CLASS_LAN:
  2772. i2o_proc_create_entries(dev, lan_entries, dir);
  2773. switch(dev->lct_data.sub_class)
  2774. {
  2775. case I2O_LAN_ETHERNET:
  2776. i2o_proc_create_entries(dev, lan_eth_entries, dir);
  2777. break;
  2778. case I2O_LAN_FDDI:
  2779. i2o_proc_create_entries(dev, lan_fddi_entries, dir);
  2780. break;
  2781. case I2O_LAN_TR:
  2782. i2o_proc_create_entries(dev, lan_tr_entries, dir);
  2783. break;
  2784. default:
  2785. break;
  2786. }
  2787. break;
  2788. default:
  2789. break;
  2790. }
  2791. }
  2792. static void i2o_proc_remove_controller(struct i2o_controller *pctrl, 
  2793.        struct proc_dir_entry *parent)
  2794. {
  2795. char buff[10];
  2796. struct i2o_device *dev;
  2797. /* Remove unused device entries */
  2798. for(dev=pctrl->devices; dev; dev=dev->next)
  2799. i2o_proc_remove_device(dev);
  2800. if(!atomic_read(&pctrl->proc_entry->count))
  2801. {
  2802. sprintf(buff, "iop%d", pctrl->unit);
  2803. i2o_proc_remove_entries(generic_iop_entries, pctrl->proc_entry);
  2804. remove_proc_entry(buff, parent);
  2805. pctrl->proc_entry = NULL;
  2806. }
  2807. }
  2808. void i2o_proc_remove_device(struct i2o_device *dev)
  2809. {
  2810. struct proc_dir_entry *de=dev->proc_entry;
  2811. char dev_id[10];
  2812. sprintf(dev_id, "%0#5x", dev->lct_data.tid);
  2813. i2o_device_notify_off(dev, &i2o_proc_handler);
  2814. /* Would it be safe to remove _files_ even if they are in use? */
  2815. if((de) && (!atomic_read(&de->count)))
  2816. {
  2817. i2o_proc_remove_entries(generic_dev_entries, de);
  2818. switch(dev->lct_data.class_id)
  2819. {
  2820. case I2O_CLASS_SCSI_PERIPHERAL:
  2821. case I2O_CLASS_RANDOM_BLOCK_STORAGE:
  2822. i2o_proc_remove_entries(rbs_dev_entries, de);
  2823. break;
  2824. case I2O_CLASS_LAN:
  2825. {
  2826. i2o_proc_remove_entries(lan_entries, de);
  2827. switch(dev->lct_data.sub_class)
  2828. {
  2829. case I2O_LAN_ETHERNET:
  2830. i2o_proc_remove_entries(lan_eth_entries, de);
  2831. break;
  2832. case I2O_LAN_FDDI:
  2833. i2o_proc_remove_entries(lan_fddi_entries, de);
  2834. break;
  2835. case I2O_LAN_TR:
  2836. i2o_proc_remove_entries(lan_tr_entries, de);
  2837. break;
  2838. }
  2839. }
  2840. remove_proc_entry(dev_id, dev->controller->proc_entry);
  2841. }
  2842. }
  2843. }
  2844. void i2o_proc_dev_del(struct i2o_controller *c, struct i2o_device *d)
  2845. {
  2846. #ifdef DRIVERDEBUG
  2847. printk(KERN_INFO "Deleting device %d from iop%dn", 
  2848. d->lct_data.tid, c->unit);
  2849. #endif
  2850. i2o_proc_remove_device(d);
  2851. }
  2852. static int create_i2o_procfs(void)
  2853. {
  2854. struct i2o_controller *pctrl = NULL;
  2855. int i;
  2856. i2o_proc_dir_root = proc_mkdir("i2o", 0);
  2857. if(!i2o_proc_dir_root)
  2858. return -1;
  2859. for(i = 0; i < MAX_I2O_CONTROLLERS; i++)
  2860. {
  2861. pctrl = i2o_find_controller(i);
  2862. if(pctrl)
  2863. {
  2864. i2o_proc_add_controller(pctrl, i2o_proc_dir_root);
  2865. i2o_unlock_controller(pctrl);
  2866. }
  2867. };
  2868. return 0;
  2869. }
  2870. static int __exit destroy_i2o_procfs(void)
  2871. {
  2872. struct i2o_controller *pctrl = NULL;
  2873. int i;
  2874. for(i = 0; i < MAX_I2O_CONTROLLERS; i++)
  2875. {
  2876. pctrl = i2o_find_controller(i);
  2877. if(pctrl)
  2878. {
  2879. i2o_proc_remove_controller(pctrl, i2o_proc_dir_root);
  2880. i2o_unlock_controller(pctrl);
  2881. }
  2882. }
  2883. if(!atomic_read(&i2o_proc_dir_root->count))
  2884. remove_proc_entry("i2o", 0);
  2885. else
  2886. return -1;
  2887. return 0;
  2888. }
  2889. int __init i2o_proc_init(void)
  2890. {
  2891. if (i2o_install_handler(&i2o_proc_handler) < 0)
  2892. {
  2893. printk(KERN_ERR "i2o_proc: Unable to install PROC handler.n");
  2894. return 0;
  2895. }
  2896. if(create_i2o_procfs())
  2897. return -EBUSY;
  2898. return 0;
  2899. }
  2900. MODULE_AUTHOR("Deepak Saxena");
  2901. MODULE_DESCRIPTION("I2O procfs Handler");
  2902. MODULE_LICENSE("GPL");
  2903. static void __exit i2o_proc_exit(void)
  2904. {
  2905. destroy_i2o_procfs();
  2906. i2o_remove_handler(&i2o_proc_handler);
  2907. }
  2908. module_init(i2o_proc_init);
  2909. module_exit(i2o_proc_exit);