1 /*---------------------------------------------------------------------------
2 FT1000 driver for Flarion Flash OFDM NIC Device
4 Copyright (C) 2006 Patrik Ostrihon, All rights reserved.
5 Copyright (C) 2006 ProWeb Consulting, a.s, All rights reserved.
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your option) any
10 later version. This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details. You should have received a copy of the GNU General Public
14 License along with this program; if not, write to the
15 Free Software Foundation, Inc., 59 Temple Place -
16 Suite 330, Boston, MA 02111-1307, USA.
17 -----------------------------------------------------------------------------*/
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/proc_fs.h>
22 #include <linux/string.h>
23 #include <linux/vmalloc.h>
24 #include <linux/netdevice.h>
25 #include <asm/uaccess.h>
28 #define FT1000_PROC "ft1000"
29 #define MAX_FILE_LEN 255
31 #define PUTM_TO_PAGE(len,page,args...) \
32 len += snprintf(page+len, PAGE_SIZE - len, args)
34 #define PUTX_TO_PAGE(len,page,message,size,var) \
35 len += snprintf(page+len, PAGE_SIZE - len, message); \
36 for(i = 0; i < (size - 1); i++) \
38 len += snprintf(page+len, PAGE_SIZE - len, "%02x:", var[i]); \
40 len += snprintf(page+len, PAGE_SIZE - len, "%02x\n", var[i])
42 #define PUTD_TO_PAGE(len,page,message,size,var) \
43 len += snprintf(page+len, PAGE_SIZE - len, message); \
44 for(i = 0; i < (size - 1); i++) \
46 len += snprintf(page+len, PAGE_SIZE - len, "%d.", var[i]); \
48 len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i])
50 int ft1000ReadProc(char *page
, char **start
, off_t off
,
51 int count
, int *eof
, void *data
)
53 struct net_device
*dev
;
58 { "Idle (Disconnect)", "Searching", "Active (Connected)",
59 "Waiting for L2", "Sleep", "No Coverage", "", ""
61 char *signal
[] = { "", "*", "**", "***", "****" };
67 dev
= (struct net_device
*)data
;
68 info
= netdev_priv(dev
);
77 if (info
->AsicID
== ELECTRABUZZ_ID
) {
78 if (info
->DspHibernateFlag
== 0) {
79 if (info
->ProgConStat
!= 0xFF) {
81 ft1000_read_dpram(dev
, FT1000_DSP_LED
);
83 ft1000_read_dpram(dev
,
84 FT1000_DSP_CON_STATE
);
90 if (info
->ProgConStat
!= 0xFF) {
92 ntohs(ft1000_read_dpram_mag_16
93 (dev
, FT1000_MAG_DSP_LED
,
94 FT1000_MAG_DSP_LED_INDX
));
96 ntohs(ft1000_read_dpram_mag_16
97 (dev
, FT1000_MAG_DSP_CON_STATE
,
98 FT1000_MAG_DSP_CON_STATE_INDX
));
104 i
= (info
->LedStat
) & 0xf;
122 i
= (info
->LedStat
>> 8) & 0xf;
140 do_gettimeofday(&tv
);
141 delta
= (tv
.tv_sec
- info
->ConTm
);
143 PUTM_TO_PAGE(len
, page
, "Connection Time: %02ld:%02ld:%02ld\n",
144 ((delta
/ 3600) % 24), ((delta
/ 60) % 60), (delta
% 60));
145 PUTM_TO_PAGE(len
, page
, "Connection Time[s]: %ld\n", delta
);
146 PUTM_TO_PAGE(len
, page
, "Asic ID: %s\n",
148 ELECTRABUZZ_ID
? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC");
149 PUTX_TO_PAGE(len
, page
, "SKU: ", SKUSZ
, info
->Sku
);
150 PUTX_TO_PAGE(len
, page
, "EUI64: ", EUISZ
, info
->eui64
);
151 PUTD_TO_PAGE(len
, page
, "DSP version number: ", DSPVERSZ
, info
->DspVer
);
152 PUTX_TO_PAGE(len
, page
, "Hardware Serial Number: ", HWSERNUMSZ
,
154 PUTX_TO_PAGE(len
, page
, "Caliberation Version: ", CALVERSZ
,
156 PUTD_TO_PAGE(len
, page
, "Caliberation Date: ", CALDATESZ
,
158 PUTM_TO_PAGE(len
, page
, "Media State: %s\n",
159 (info
->mediastate
) ? "link" : "no link");
160 PUTM_TO_PAGE(len
, page
, "Connection Status: %s\n",
161 status
[((info
->ConStat
) & 0x7)]);
162 PUTM_TO_PAGE(len
, page
, "RX packets: %ld\n", info
->stats
.rx_packets
);
163 PUTM_TO_PAGE(len
, page
, "TX packets: %ld\n", info
->stats
.tx_packets
);
164 PUTM_TO_PAGE(len
, page
, "RX bytes: %ld\n", info
->stats
.rx_bytes
);
165 PUTM_TO_PAGE(len
, page
, "TX bytes: %ld\n", info
->stats
.tx_bytes
);
166 PUTM_TO_PAGE(len
, page
, "Signal Strength: %s\n", signal
[strength
]);
167 PUTM_TO_PAGE(len
, page
, "Signal Quality: %s\n", signal
[quality
]);
171 static int ft1000NotifyProc(struct notifier_block
*this, unsigned long event
,
174 struct net_device
*dev
= ptr
;
177 info
= netdev_priv(dev
);
180 case NETDEV_CHANGENAME
:
181 remove_proc_entry(info
->netdevname
, info
->proc_ft1000
);
182 create_proc_read_entry(dev
->name
, 0644, info
->proc_ft1000
,
183 ft1000ReadProc
, dev
);
184 snprintf(info
->netdevname
, IFNAMSIZ
, "%s", dev
->name
);
190 static struct notifier_block ft1000_netdev_notifier
= {
191 .notifier_call
= ft1000NotifyProc
194 void ft1000InitProc(struct net_device
*dev
)
198 info
= netdev_priv(dev
);
200 info
->proc_ft1000
= proc_mkdir(FT1000_PROC
, init_net
.proc_net
);
201 create_proc_read_entry(dev
->name
, 0644, info
->proc_ft1000
,
202 ft1000ReadProc
, dev
);
203 snprintf(info
->netdevname
, IFNAMSIZ
, "%s", dev
->name
);
204 register_netdevice_notifier(&ft1000_netdev_notifier
);
207 void ft1000CleanupProc(struct net_device
*dev
)
211 info
= netdev_priv(dev
);
213 remove_proc_entry(dev
->name
, info
->proc_ft1000
);
214 remove_proc_entry(FT1000_PROC
, init_net
.proc_net
);
215 unregister_netdevice_notifier(&ft1000_netdev_notifier
);