1
2
3
4
5
6
7
8
9
10
11
12
13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
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"
28#include "sbeproc.h"
29
30extern void sbecom_get_brdinfo(ci_t *, struct sbe_brd_info *, u_int8_t *);
31extern struct s_hdw_info hdw_info[MAX_BOARDS];
32
33void sbecom_proc_brd_cleanup(ci_t *ci)
34{
35 if (ci->dir_dev) {
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);
40 ci->dir_dev = NULL;
41 }
42}
43
44static void sbecom_proc_get_brdinfo(ci_t *ci, struct sbe_brd_info *bip)
45{
46 hdw_info_t *hi = &hdw_info[ci->brdno];
47 u_int8_t *bsn = 0;
48
49 switch (hi->promfmt)
50 {
51 case PROM_FORMAT_TYPE1:
52 bsn = (u_int8_t *) hi->mfg_info.pft1.Serial;
53 break;
54 case PROM_FORMAT_TYPE2:
55 bsn = (u_int8_t *) hi->mfg_info.pft2.Serial;
56 break;
57 }
58
59 sbecom_get_brdinfo (ci, bip, bsn);
60
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);
64}
65
66
67
68
69static int sbecom_proc_get_sbe_info(struct seq_file *m, void *v)
70{
71 ci_t *ci = m->private;
72 char *spd;
73 struct sbe_brd_info *bip;
74
75 if (!(bip = OS_kmalloc(sizeof(struct sbe_brd_info))))
76 return -ENOMEM;
77
78 pr_devel(">> sbecom_proc_get_sbe_info: entered\n");
79
80 sbecom_proc_get_brdinfo(ci, bip);
81
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");
86 break;
87 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1):
88 seq_puts(m, "wanPTMC-256T3 <E1>");
89 break;
90 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1):
91 seq_puts(m, "wanPTMC-256T3 <T1>");
92 break;
93 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_C24TE1):
94 seq_puts(m, "wanPTMC-C24TE1");
95 break;
96
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");
100 break;
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");
104 break;
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");
108 break;
109
110 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1):
111 seq_puts(m, "wanPCI-C4T1E1");
112 break;
113 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1):
114 seq_puts(m, "wanPCI-C2T1E1");
115 break;
116 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1):
117 seq_puts(m, "wanPCI-C1T1E1");
118 break;
119
120 default:
121 seq_puts(m, "unknown");
122 break;
123 }
124
125 seq_printf(m, " [%08X]\n", bip->brd_id);
126
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);
133#if 1
134 seq_printf(m, "Interface: %s -> %s\n",
135 bip->first_iname, bip->last_iname);
136#else
137 seq_printf(m, "Interface: <not available> 1st %p lst %p\n",
138 bip->first_iname, bip->last_iname);
139#endif
140
141 switch (bip->brd_pci_speed) {
142 case BINFO_PCI_SPEED_33:
143 spd = "33Mhz";
144 break;
145 case BINFO_PCI_SPEED_66:
146 spd = "66Mhz";
147 break;
148 default:
149 spd = "<not available>";
150 break;
151 }
152 seq_printf(m, "PCI Bus Speed: %s\n", spd);
153 seq_printf(m, "Release: %s\n", ci->release);
154
155#ifdef SBE_PMCC4_ENABLE
156 {
157 extern int cxt1e1_max_mru;
158#if 0
159 extern int max_chans_used;
160 extern int cxt1e1_max_mtu;
161#endif
162 extern int max_rxdesc_used, max_txdesc_used;
163
164 seq_printf(m, "\ncxt1e1_max_mru: %d\n", cxt1e1_max_mru);
165#if 0
166 seq_printf(m, "\nmax_chans_used: %d\n", max_chans_used);
167 seq_printf(m, "cxt1e1_max_mtu: %d\n", cxt1e1_max_mtu);
168#endif
169 seq_printf(m, "max_rxdesc_used: %d\n", max_rxdesc_used);
170 seq_printf(m, "max_txdesc_used: %d\n", max_txdesc_used);
171 }
172#endif
173
174 kfree(bip);
175
176 pr_devel(">> proc_fs: finished\n");
177 return 0;
178}
179
180
181
182
183static int sbecom_proc_open(struct inode *inode, struct file *file)
184{
185 return single_open(file, sbecom_proc_get_sbe_info, PDE_DATA(inode));
186}
187
188static const struct file_operations sbecom_proc_fops = {
189 .open = sbecom_proc_open,
190 .read = seq_read,
191 .llseek = seq_lseek,
192 .release = single_release,
193};
194
195
196
197
198int __init sbecom_proc_brd_init(ci_t *ci)
199{
200 char dir[7 + SBE_IFACETMPL_SIZE + 1];
201
202 snprintf(dir, sizeof(dir), "driver/%s", ci->devname);
203 ci->dir_dev = proc_mkdir(dir, NULL);
204 if (!ci->dir_dev) {
205 pr_err("Unable to create directory /proc/driver/%s\n", ci->devname);
206 goto fail;
207 }
208
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);
212 goto fail;
213 }
214 return 0;
215
216fail:
217 sbecom_proc_brd_cleanup(ci);
218 return 1;
219}
220