Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rtl871x_ioctl_rtl.c
Go to the documentation of this file.
1 /******************************************************************************
2  * rtl871x_ioctl_rtl.c
3  *
4  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5  * Linux device driver for RTL8192SU
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of version 2 of the GNU General Public License as
9  * published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19  *
20  * Modifications for inclusion into the Linux staging tree are
21  * Copyright(c) 2010 Larry Finger. All rights reserved.
22  *
23  * Contact information:
24  * WLAN FAE <[email protected]>
25  * Larry Finger <[email protected]>
26  *
27  ******************************************************************************/
28 
29 #define _RTL871X_IOCTL_RTL_C_
30 
31 #include "osdep_service.h"
32 #include "drv_types.h"
33 #include "wlan_bssdef.h"
34 #include "wifi.h"
35 #include "rtl871x_ioctl.h"
36 #include "rtl871x_ioctl_set.h"
37 #include "rtl871x_ioctl_rtl.h"
38 #include "mp_custom_oid.h"
39 #include "rtl871x_mp.h"
40 #include "rtl871x_mp_ioctl.h"
41 
43 {
44  if (poid_par_priv->type_of_oid != QUERY_OID)
46  return NDIS_STATUS_SUCCESS;
47 }
48 
50 {
51  struct _adapter *padapter = (struct _adapter *)
52  (poid_par_priv->adapter_context);
53 
54  if (poid_par_priv->type_of_oid != QUERY_OID)
56  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
57  *(u32 *)poid_par_priv->information_buf =
58  padapter->recvpriv.rx_smallpacket_crcerr;
59  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
60  } else
62  return NDIS_STATUS_SUCCESS;
63 }
64 
66 {
67  struct _adapter *padapter = (struct _adapter *)
68  (poid_par_priv->adapter_context);
69 
70  if (poid_par_priv->type_of_oid != QUERY_OID)
72  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
73  *(u32 *)poid_par_priv->information_buf =
74  padapter->recvpriv.rx_middlepacket_crcerr;
75  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
76  } else
78  return NDIS_STATUS_SUCCESS;
79 }
80 
82 {
83  struct _adapter *padapter = (struct _adapter *)
84  (poid_par_priv->adapter_context);
85 
86  if (poid_par_priv->type_of_oid != QUERY_OID)
88  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
89  *(u32 *)poid_par_priv->information_buf =
90  padapter->recvpriv.rx_largepacket_crcerr;
91  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
92  } else
94  return NDIS_STATUS_SUCCESS;
95 }
96 
98 {
99  if (poid_par_priv->type_of_oid != QUERY_OID)
101  return NDIS_STATUS_SUCCESS;
102 }
103 
105 {
106  if (poid_par_priv->type_of_oid != QUERY_OID)
108  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
109  return NDIS_STATUS_SUCCESS;
110 }
111 
113 {
114  struct _adapter *padapter = (struct _adapter *)
115  (poid_par_priv->adapter_context);
116 
117  if (poid_par_priv->type_of_oid != QUERY_OID)
119  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
120  *(u32 *)poid_par_priv->information_buf =
121  padapter->recvpriv.rx_pkts +
122  padapter->recvpriv.rx_drop;
123  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
124  } else
126  return NDIS_STATUS_SUCCESS;
127 }
128 
130 {
131  if (poid_par_priv->type_of_oid != QUERY_OID)
133  return NDIS_STATUS_SUCCESS;
134 }
135 
137 {
138  if (poid_par_priv->type_of_oid != QUERY_OID)
140  return NDIS_STATUS_SUCCESS;
141 }
142 
144 {
145  struct _adapter *padapter = (struct _adapter *)
146  (poid_par_priv->adapter_context);
147 
148  if (poid_par_priv->type_of_oid != QUERY_OID)
150  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
151  *(uint *)poid_par_priv->information_buf =
152  padapter->recvpriv.rx_icv_err;
153  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
154  } else
156  return NDIS_STATUS_SUCCESS;
157 }
158 
160  *poid_par_priv)
161 {
162  if (poid_par_priv->type_of_oid != SET_OID)
164  return NDIS_STATUS_SUCCESS;
165 }
166 
168 {
169  struct _adapter *padapter = (struct _adapter *)
170  (poid_par_priv->adapter_context);
171  u32 preamblemode = 0 ;
172 
173  if (poid_par_priv->type_of_oid != QUERY_OID)
175  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
176  if (padapter->registrypriv.preamble == PREAMBLE_LONG)
177  preamblemode = 0;
178  else if (padapter->registrypriv.preamble == PREAMBLE_AUTO)
179  preamblemode = 1;
180  else if (padapter->registrypriv.preamble == PREAMBLE_SHORT)
181  preamblemode = 2;
182  *(u32 *)poid_par_priv->information_buf = preamblemode;
183  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
184  } else
186  return NDIS_STATUS_SUCCESS;
187 }
188 
189 uint oid_rt_get_ap_ip_hdl(struct oid_par_priv *poid_par_priv)
190 {
191  if (poid_par_priv->type_of_oid != QUERY_OID)
193  return NDIS_STATUS_SUCCESS;
194 }
195 
197 {
198  struct _adapter *padapter = (struct _adapter *)
199  (poid_par_priv->adapter_context);
200  struct eeprom_priv *peeprompriv = &padapter->eeprompriv;
201 
202  if (poid_par_priv->type_of_oid != QUERY_OID)
204  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
205  *(u16 *)poid_par_priv->information_buf = peeprompriv->channel_plan;
206  return NDIS_STATUS_SUCCESS;
207 }
208 
210  *poid_par_priv)
211 {
212  struct _adapter *padapter = (struct _adapter *)
213  (poid_par_priv->adapter_context);
214  struct eeprom_priv *peeprompriv = &padapter->eeprompriv;
215 
216  if (poid_par_priv->type_of_oid != SET_OID)
218  peeprompriv->channel_plan = *(u16 *)poid_par_priv->information_buf;
219  return NDIS_STATUS_SUCCESS;
220 }
221 
223  *poid_par_priv)
224 {
225  struct _adapter *padapter = (struct _adapter *)
226  (poid_par_priv->adapter_context);
227  u32 preamblemode = 0;
228 
229  if (poid_par_priv->type_of_oid != SET_OID)
231  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
232  preamblemode = *(u32 *)poid_par_priv->information_buf;
233  if (preamblemode == 0)
234  padapter->registrypriv.preamble = PREAMBLE_LONG;
235  else if (preamblemode == 1)
236  padapter->registrypriv.preamble = PREAMBLE_AUTO;
237  else if (preamblemode == 2)
238  padapter->registrypriv.preamble = PREAMBLE_SHORT;
239  *(u32 *)poid_par_priv->information_buf = preamblemode;
240  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
241  } else
243  return NDIS_STATUS_SUCCESS;
244 }
245 
247 {
248  if (poid_par_priv->type_of_oid != SET_OID)
250  return NDIS_STATUS_SUCCESS;
251 }
252 
254  *poid_par_priv)
255 {
256  return NDIS_STATUS_SUCCESS;
257 }
258 
260  *poid_par_priv)
261 {
262  struct _adapter *padapter = (struct _adapter *)
263  (poid_par_priv->adapter_context);
264 
265  if (poid_par_priv->type_of_oid != QUERY_OID)
267  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
268  *(u32 *)poid_par_priv->information_buf =
269  padapter->xmitpriv.tx_bytes;
270  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
271  } else
273  return NDIS_STATUS_SUCCESS;
274 }
275 
277  *poid_par_priv)
278 {
279  struct _adapter *padapter = (struct _adapter *)
280  (poid_par_priv->adapter_context);
281 
282  if (poid_par_priv->type_of_oid != QUERY_OID)
284  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
285  *(u32 *)poid_par_priv->information_buf =
286  padapter->recvpriv.rx_bytes;
287  *poid_par_priv->bytes_rw = poid_par_priv->
288  information_buf_len;
289  } else
291  return NDIS_STATUS_SUCCESS;
292 }
293 
295  *poid_par_priv)
296 {
297  return NDIS_STATUS_SUCCESS;
298 }
299 
301  *poid_par_priv)
302 {
303  if (poid_par_priv->type_of_oid != QUERY_OID)
305  return NDIS_STATUS_SUCCESS;
306 }
307 
309  *poid_par_priv)
310 {
311  if (poid_par_priv->type_of_oid != QUERY_OID)
313  return NDIS_STATUS_SUCCESS;
314 }
315 
317 {
318  struct _adapter *padapter = (struct _adapter *)
319  (poid_par_priv->adapter_context);
320  struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
321  struct NDIS_802_11_CONFIGURATION *pnic_Config;
322  u32 channelnum;
323 
324  if (poid_par_priv->type_of_oid != QUERY_OID)
326  if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
327  (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true))
328  pnic_Config = &pmlmepriv->cur_network.network.Configuration;
329  else
330  pnic_Config = &padapter->registrypriv.dev_network.
332  channelnum = pnic_Config->DSConfig;
333  *(u32 *)poid_par_priv->information_buf = channelnum;
334  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
335  return NDIS_STATUS_SUCCESS;
336 }
337 
339  *poid_par_priv)
340 {
341  if (poid_par_priv->type_of_oid != QUERY_OID)
343  return NDIS_STATUS_SUCCESS;
344 }
345 
347 {
348  if (poid_par_priv->type_of_oid != QUERY_OID)
350  return NDIS_STATUS_SUCCESS;
351 }
352 
354  *poid_par_priv)
355 {
356  u32 ulInfo = 0;
357 
358  if (poid_par_priv->type_of_oid != QUERY_OID)
360  if (poid_par_priv->information_buf_len >= sizeof(u32)) {
361  ulInfo |= 0x0100; /* WIRELESS_MODE_B */
362  ulInfo |= 0x0200; /* WIRELESS_MODE_G */
363  ulInfo |= 0x0400; /* WIRELESS_MODE_A */
364  *(u32 *) poid_par_priv->information_buf = ulInfo;
365  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
366  } else
368  return NDIS_STATUS_SUCCESS;
369 }
370 
372 {
373  if (poid_par_priv->type_of_oid != QUERY_OID)
375  return NDIS_STATUS_SUCCESS;
376 }
377 
379 {
380  if (poid_par_priv->type_of_oid != QUERY_OID)
382  return NDIS_STATUS_SUCCESS;
383 }
384 
385 
387 {
388  return NDIS_STATUS_SUCCESS;
389 }
390 
392  *poid_par_priv)
393 {
394  return NDIS_STATUS_SUCCESS;
395 }
396 
398  *poid_par_priv)
399 {
400  if (poid_par_priv->type_of_oid != QUERY_OID)
402  return NDIS_STATUS_SUCCESS;
403 }
404 
406  *poid_par_priv)
407 {
408  return NDIS_STATUS_SUCCESS;
409 }
410 
412  *poid_par_priv)
413 {
414  if (poid_par_priv->type_of_oid != QUERY_OID)
416  return NDIS_STATUS_SUCCESS;
417 }
418 
420  poid_par_priv)
421 {
422  return NDIS_STATUS_SUCCESS;
423 }
424 
426 {
427  return NDIS_STATUS_SUCCESS;
428 }
429 
431 {
432  if (poid_par_priv->type_of_oid != SET_OID)
434  return NDIS_STATUS_SUCCESS;
435 }
436 
438  poid_par_priv)
439 {
441  struct _adapter *Adapter = (struct _adapter *)
442  (poid_par_priv->adapter_context);
443 
444  if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */
446  if (poid_par_priv->information_buf_len ==
447  (sizeof(unsigned long) * 3)) {
448  if (!r8712_setrfreg_cmd(Adapter,
449  *(unsigned char *)poid_par_priv->information_buf,
450  (unsigned long)(*((unsigned long *)
451  poid_par_priv->information_buf + 2))))
452  status = NDIS_STATUS_NOT_ACCEPTED;
453  } else
455  return status;
456 }
457 
459 {
461  struct _adapter *Adapter = (struct _adapter *)
462  (poid_par_priv->adapter_context);
463 
464  if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */
466  if (poid_par_priv->information_buf_len == (sizeof(unsigned long)*3)) {
467  if (Adapter->mppriv.act_in_progress == true)
468  status = NDIS_STATUS_NOT_ACCEPTED;
469  else {
470  /* init workparam */
471  Adapter->mppriv.act_in_progress = true;
472  Adapter->mppriv.workparam.bcompleted = false;
473  Adapter->mppriv.workparam.act_type = MPT_READ_RF;
474  Adapter->mppriv.workparam.io_offset = *(unsigned long *)
475  poid_par_priv->information_buf;
476  Adapter->mppriv.workparam.io_value = 0xcccccccc;
477 
478  /* RegOffsetValue - The offset of RF register to read.
479  * RegDataWidth - The data width of RF register to read.
480  * RegDataValue - The value to read.
481  * RegOffsetValue = *((unsigned long *)InformationBuffer);
482  * RegDataWidth = *((unsigned long *)InformationBuffer+1);
483  * RegDataValue = *((unsigned long *)InformationBuffer+2);
484  */
485  if (!r8712_getrfreg_cmd(Adapter,
486  *(unsigned char *)poid_par_priv->information_buf,
487  (unsigned char *)&Adapter->mppriv.workparam.
488  io_value))
489  status = NDIS_STATUS_NOT_ACCEPTED;
490  }
491  } else
493  return status;
494 }
495 
501 };
502 
504 {
505  struct _adapter *padapter = (struct _adapter *)
506  (poid_par_priv->adapter_context);
507  struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
508  u32 ulInfo;
509 
510  if (poid_par_priv->type_of_oid != QUERY_OID)
512  /* nStatus==0 CheckingStatus
513  * nStatus==1 Associated
514  * nStatus==2 AdHocMode
515  * nStatus==3 NotAssociated
516  */
517  if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)
518  ulInfo = CHECKINGSTATUS;
519  else if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
520  ulInfo = ASSOCIATED;
521  else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)
522  ulInfo = ADHOCMODE;
523  else
524  ulInfo = NOTASSOCIATED ;
525  *(u32 *)poid_par_priv->information_buf = ulInfo;
526  *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
527  return NDIS_STATUS_SUCCESS;
528 }
529 
531 {
532  if (poid_par_priv->type_of_oid != SET_OID)
534  return NDIS_STATUS_SUCCESS;
535 }