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 bip
= kzalloc(sizeof(struct sbe_brd_info
), GFP_KERNEL
| GFP_DMA
);
79 pr_devel(">> sbecom_proc_get_sbe_info: entered\n");
81 sbecom_proc_get_brdinfo(ci
, bip
);
83 seq_puts(m
, "Board Type: ");
84 switch (bip
->brd_id
) {
85 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C1T3
):
86 seq_puts(m
, "wanPMC-C1T3");
88 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPTMC_256T3_E1
):
89 seq_puts(m
, "wanPTMC-256T3 <E1>");
91 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPTMC_256T3_T1
):
92 seq_puts(m
, "wanPTMC-256T3 <T1>");
94 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPTMC_C24TE1
):
95 seq_puts(m
, "wanPTMC-C24TE1");
98 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C4T1E1
):
99 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C4T1E1_L
):
100 seq_puts(m
, "wanPMC-C4T1E1");
102 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C2T1E1
):
103 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C2T1E1_L
):
104 seq_puts(m
, "wanPMC-C2T1E1");
106 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C1T1E1
):
107 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPMC_C1T1E1_L
):
108 seq_puts(m
, "wanPMC-C1T1E1");
111 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPCI_C4T1E1
):
112 seq_puts(m
, "wanPCI-C4T1E1");
114 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPCI_C2T1E1
):
115 seq_puts(m
, "wanPCI-C2T1E1");
117 case SBE_BOARD_ID(PCI_VENDOR_ID_SBE
, PCI_DEVICE_ID_WANPCI_C1T1E1
):
118 seq_puts(m
, "wanPCI-C1T1E1");
122 seq_puts(m
, "unknown");
126 seq_printf(m
, " [%08X]\n", bip
->brd_id
);
128 seq_printf(m
, "Board Number: %d\n", bip
->brdno
);
129 seq_printf(m
, "Hardware ID: 0x%02X\n", ci
->hdw_bid
);
130 seq_printf(m
, "Board SN: %06X\n", bip
->brd_sn
);
131 seq_printf(m
, "Board MAC: %pMF\n", bip
->brd_mac_addr
);
132 seq_printf(m
, "Ports: %d\n", ci
->max_port
);
133 seq_printf(m
, "Channels: %d\n", bip
->brd_chan_cnt
);
135 seq_printf(m
, "Interface: %s -> %s\n",
136 bip
->first_iname
, bip
->last_iname
);
138 seq_printf(m
, "Interface: <not available> 1st %p lst %p\n",
139 bip
->first_iname
, bip
->last_iname
);
142 switch (bip
->brd_pci_speed
) {
143 case BINFO_PCI_SPEED_33
:
146 case BINFO_PCI_SPEED_66
:
150 spd
= "<not available>";
153 seq_printf(m
, "PCI Bus Speed: %s\n", spd
);
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
);