1 /* Copyright (C) 2004-2005 SBE, Inc.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16 #include <linux/types.h>
17 #include <linux/module.h>
18 #include <linux/errno.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/proc_fs.h>
22 #include <linux/seq_file.h>
23 #include <linux/sched.h>
24 #include <asm/uaccess.h>
25 #include "pmcc4_sysdep.h"
26 #include "sbecom_inline_linux.h"
27 #include "pmcc4_private.h"
30 extern void sbecom_get_brdinfo(ci_t
*, struct sbe_brd_info
*, u_int8_t
*);
31 extern struct s_hdw_info hdw_info
[MAX_BOARDS
];
33 void sbecom_proc_brd_cleanup(ci_t
*ci
)
36 char dir
[7 + SBE_IFACETMPL_SIZE
+ 1];
37 snprintf(dir
, sizeof(dir
), "driver/%s", ci
->devname
);
38 remove_proc_entry("info", ci
->dir_dev
);
39 remove_proc_entry(dir
, NULL
);
44 static void sbecom_proc_get_brdinfo(ci_t
*ci
, struct sbe_brd_info
*bip
)
46 hdw_info_t
*hi
= &hdw_info
[ci
->brdno
];
51 case PROM_FORMAT_TYPE1
:
52 bsn
= (u_int8_t
*) hi
->mfg_info
.pft1
.Serial
;
54 case PROM_FORMAT_TYPE2
:
55 bsn
= (u_int8_t
*) hi
->mfg_info
.pft2
.Serial
;
59 sbecom_get_brdinfo (ci
, bip
, bsn
);
61 pr_devel(">> sbecom_get_brdinfo: returned, first_if %p <%s> last_if %p <%s>\n",
62 bip
->first_iname
, bip
->first_iname
,
63 bip
->last_iname
, bip
->last_iname
);
67 * Describe the driver state through /proc
69 static int sbecom_proc_get_sbe_info(struct seq_file
*m
, void *v
)
71 ci_t
*ci
= m
->private;
73 struct sbe_brd_info
*bip
;
75 if (!(bip
= OS_kmalloc(sizeof(struct sbe_brd_info
))))
78 pr_devel(">> sbecom_proc_get_sbe_info: entered\n");
80 sbecom_proc_get_brdinfo(ci
, bip
);
82 seq_puts(m
, "Board Type: ");
83 switch (bip
->brd_id
) {
84 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C1T3
):
85 seq_puts(m
, "wanPMC-C1T3");
87 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPTMC_256T3_E1
):
88 seq_puts(m
, "wanPTMC-256T3 <E1>");
90 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPTMC_256T3_T1
):
91 seq_puts(m
, "wanPTMC-256T3 <T1>");
93 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPTMC_C24TE1
):
94 seq_puts(m
, "wanPTMC-C24TE1");
97 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C4T1E1
):
98 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C4T1E1_L
):
99 seq_puts(m
, "wanPMC-C4T1E1");
101 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C2T1E1
):
102 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C2T1E1_L
):
103 seq_puts(m
, "wanPMC-C2T1E1");
105 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C1T1E1
):
106 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C1T1E1_L
):
107 seq_puts(m
, "wanPMC-C1T1E1");
110 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPCI_C4T1E1
):
111 seq_puts(m
, "wanPCI-C4T1E1");
113 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPCI_C2T1E1
):
114 seq_puts(m
, "wanPCI-C2T1E1");
116 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPCI_C1T1E1
):
117 seq_puts(m
, "wanPCI-C1T1E1");
121 seq_puts(m
, "unknown");
125 seq_printf(m
, " [%08X]\n", bip
->brd_id
);
127 seq_printf(m
, "Board Number: %d\n", bip
->brdno
);
128 seq_printf(m
, "Hardware ID: 0x%02X\n", ci
->hdw_bid
);
129 seq_printf(m
, "Board SN: %06X\n", bip
->brd_sn
);
130 seq_printf(m
, "Board MAC: %pMF\n", bip
->brd_mac_addr
);
131 seq_printf(m
, "Ports: %d\n", ci
->max_port
);
132 seq_printf(m
, "Channels: %d\n", bip
->brd_chan_cnt
);
134 seq_printf(m
, "Interface: %s -> %s\n",
135 bip
->first_iname
, bip
->last_iname
);
137 seq_printf(m
, "Interface: <not available> 1st %p lst %p\n",
138 bip
->first_iname
, bip
->last_iname
);
141 switch (bip
->brd_pci_speed
) {
142 case BINFO_PCI_SPEED_33
:
145 case BINFO_PCI_SPEED_66
:
149 spd
= "<not available>";
152 seq_printf(m
, "PCI Bus Speed: %s\n", spd
);
153 seq_printf(m
, "Release: %s\n", ci
->release
);
155 #ifdef SBE_PMCC4_ENABLE
157 extern int cxt1e1_max_mru
;
159 extern int max_chans_used
;
160 extern int cxt1e1_max_mtu
;
162 extern int max_rxdesc_used
, max_txdesc_used
;
164 seq_printf(m
, "\ncxt1e1_max_mru: %d\n", cxt1e1_max_mru
);
166 seq_printf(m
, "\nmax_chans_used: %d\n", max_chans_used
);
167 seq_printf(m
, "cxt1e1_max_mtu: %d\n", cxt1e1_max_mtu
);
169 seq_printf(m
, "max_rxdesc_used: %d\n", max_rxdesc_used
);
170 seq_printf(m
, "max_txdesc_used: %d\n", max_txdesc_used
);
176 pr_devel(">> proc_fs: finished\n");
181 * seq_file wrappers for procfile show routines.
183 static int sbecom_proc_open(struct inode
*inode
, struct file
*file
)
185 return single_open(file
, sbecom_proc_get_sbe_info
, PDE_DATA(inode
));
188 static const struct file_operations sbecom_proc_fops
= {
189 .open
= sbecom_proc_open
,
192 .release
= single_release
,
196 * Initialize the /proc subsystem for the specific SBE driver
198 int __init
sbecom_proc_brd_init(ci_t
*ci
)
200 char dir
[7 + SBE_IFACETMPL_SIZE
+ 1];
202 snprintf(dir
, sizeof(dir
), "driver/%s", ci
->devname
);
203 ci
->dir_dev
= proc_mkdir(dir
, NULL
);
205 pr_err("Unable to create directory /proc/driver/%s\n", ci
->devname
);
209 if (!proc_create_data("info", S_IFREG
| S_IRUGO
, ci
->dir_dev
,
210 &sbecom_proc_fops
, ci
)) {
211 pr_err("Unable to create entry /proc/driver/%s/info\n", ci
->devname
);
217 sbecom_proc_brd_cleanup(ci
);