1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
17 #include <rtw_debug.h>
18 #include <usb_ops_linux.h>
20 int proc_get_drv_version(char *page, char **start,
21 off_t offset, int count,
26 len += snprintf(page + len, count - len, "%s\n", DRIVERVERSION);
32 int proc_get_write_reg(char *page, char **start,
33 off_t offset, int count,
40 int proc_set_write_reg(struct file *file, const char __user *buffer,
41 unsigned long count, void *data)
43 struct net_device *dev = data;
44 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
49 DBG_88E("argument size is less than 3\n");
53 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
54 int num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
57 DBG_88E("invalid write_reg parameter!\n");
62 usb_write8(padapter, addr, (u8)val);
65 usb_write16(padapter, addr, (u16)val);
68 usb_write32(padapter, addr, val);
71 DBG_88E("error write length =%d", len);
78 static u32 proc_get_read_addr = 0xeeeeeeee;
79 static u32 proc_get_read_len = 0x4;
81 int proc_get_read_reg(char *page, char **start,
82 off_t offset, int count,
85 struct net_device *dev = data;
86 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
90 if (proc_get_read_addr == 0xeeeeeeee) {
95 switch (proc_get_read_len) {
97 len += snprintf(page + len, count - len, "usb_read8(0x%x)=0x%x\n", proc_get_read_addr, usb_read8(padapter, proc_get_read_addr));
100 len += snprintf(page + len, count - len, "usb_read16(0x%x)=0x%x\n", proc_get_read_addr, usb_read16(padapter, proc_get_read_addr));
103 len += snprintf(page + len, count - len, "usb_read32(0x%x)=0x%x\n", proc_get_read_addr, usb_read32(padapter, proc_get_read_addr));
106 len += snprintf(page + len, count - len, "error read length=%d\n", proc_get_read_len);
114 int proc_set_read_reg(struct file *file, const char __user *buffer,
115 unsigned long count, void *data)
121 DBG_88E("argument size is less than 2\n");
125 if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
126 int num = sscanf(tmp, "%x %x", &addr, &len);
129 DBG_88E("invalid read_reg parameter!\n");
133 proc_get_read_addr = addr;
135 proc_get_read_len = len;
141 int proc_get_adapter_state(char *page, char **start,
142 off_t offset, int count,
143 int *eof, void *data)
145 struct net_device *dev = data;
146 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
149 len += snprintf(page + len, count - len, "bSurpriseRemoved=%d, bDriverStopped=%d\n",
150 padapter->bSurpriseRemoved, padapter->bDriverStopped);
156 int proc_get_best_channel(char *page, char **start,
157 off_t offset, int count,
158 int *eof, void *data)
160 struct net_device *dev = data;
161 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
162 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
164 u32 i, best_channel_24G = 1, best_channel_5G = 36, index_24G = 0, index_5G = 0;
166 for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) {
167 if (pmlmeext->channel_set[i].ChannelNum == 1)
169 if (pmlmeext->channel_set[i].ChannelNum == 36)
173 for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) {
175 if (pmlmeext->channel_set[i].ChannelNum == 6) {
176 if (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_24G].rx_count) {
178 best_channel_24G = pmlmeext->channel_set[i].ChannelNum;
183 if (pmlmeext->channel_set[i].ChannelNum >= 36 &&
184 pmlmeext->channel_set[i].ChannelNum < 140) {
185 /* Find primary channel */
186 if (((pmlmeext->channel_set[i].ChannelNum - 36) % 8 == 0) &&
187 (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count)) {
189 best_channel_5G = pmlmeext->channel_set[i].ChannelNum;
193 if (pmlmeext->channel_set[i].ChannelNum >= 149 &&
194 pmlmeext->channel_set[i].ChannelNum < 165) {
195 /* find primary channel */
196 if (((pmlmeext->channel_set[i].ChannelNum - 149) % 8 == 0) &&
197 (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count)) {
199 best_channel_5G = pmlmeext->channel_set[i].ChannelNum;
203 len += snprintf(page + len, count - len, "The rx cnt of channel %3d = %d\n",
204 pmlmeext->channel_set[i].ChannelNum, pmlmeext->channel_set[i].rx_count);
207 len += snprintf(page + len, count - len, "best_channel_5G = %d\n", best_channel_5G);
208 len += snprintf(page + len, count - len, "best_channel_24G = %d\n", best_channel_24G);