1 /*************************************************************************
3 * 4F, No. 2 Technology 5th Rd. *
4 * Science-based Industrial Park *
5 * Hsin-chu, Taiwan, R.O.C. *
7 * (c) Copyright 2002, Ralink Technology, Inc. *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details. *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, write to the *
21 * Free Software Foundation, Inc., *
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 *************************************************************************
30 IOCTL related subroutines
34 -------- ---------- ----------------------------------------------
35 Rory Chen 01-03-2003 created
39 #include "rt_config.h"
40 #include <net/iw_handler.h>
42 #ifndef IW_ESSID_MAX_SIZE
43 /* Maximum size of the ESSID and NICKN strings */
44 #define IW_ESSID_MAX_SIZE 32
48 #define WEP_SMALL_KEY_LEN (40/8)
49 #define WEP_LARGE_KEY_LEN (104/8)
51 #define MAP_CHANNEL_ID_TO_KHZ(ch, khz) { \
54 case 1: khz = 2412000; break; \
55 case 2: khz = 2417000; break; \
56 case 3: khz = 2422000; break; \
57 case 4: khz = 2427000; break; \
58 case 5: khz = 2432000; break; \
59 case 6: khz = 2437000; break; \
60 case 7: khz = 2442000; break; \
61 case 8: khz = 2447000; break; \
62 case 9: khz = 2452000; break; \
63 case 10: khz = 2457000; break; \
64 case 11: khz = 2462000; break; \
65 case 12: khz = 2467000; break; \
66 case 13: khz = 2472000; break; \
67 case 14: khz = 2484000; break; \
68 case 36: /* UNII */ khz = 5180000; break; \
69 case 40: /* UNII */ khz = 5200000; break; \
70 case 44: /* UNII */ khz = 5220000; break; \
71 case 48: /* UNII */ khz = 5240000; break; \
72 case 52: /* UNII */ khz = 5260000; break; \
73 case 56: /* UNII */ khz = 5280000; break; \
74 case 60: /* UNII */ khz = 5300000; break; \
75 case 64: /* UNII */ khz = 5320000; break; \
76 case 149: /* UNII */ khz = 5745000; break; \
77 case 153: /* UNII */ khz = 5765000; break; \
78 case 157: /* UNII */ khz = 5785000; break; \
79 case 161: /* UNII */ khz = 5805000; break; \
80 case 100: /* HiperLAN2 */ khz = 5500000; break; \
81 case 104: /* HiperLAN2 */ khz = 5520000; break; \
82 case 108: /* HiperLAN2 */ khz = 5540000; break; \
83 case 112: /* HiperLAN2 */ khz = 5560000; break; \
84 case 116: /* HiperLAN2 */ khz = 5580000; break; \
85 case 120: /* HiperLAN2 */ khz = 5600000; break; \
86 case 124: /* HiperLAN2 */ khz = 5620000; break; \
87 case 128: /* HiperLAN2 */ khz = 5640000; break; \
88 case 132: /* HiperLAN2 */ khz = 5660000; break; \
89 case 136: /* HiperLAN2 */ khz = 5680000; break; \
90 case 140: /* HiperLAN2 */ khz = 5700000; break; \
91 case 34: /* Japan MMAC */ khz = 5170000; break; \
92 case 38: /* Japan MMAC */ khz = 5190000; break; \
93 case 42: /* Japan MMAC */ khz = 5210000; break; \
94 case 46: /* Japan MMAC */ khz = 5230000; break; \
95 default: khz = 2412000; break; \
99 #define MAP_KHZ_TO_CHANNEL_ID(khz, ch) { \
102 case 2412000: ch = 1; break; \
103 case 2417000: ch = 2; break; \
104 case 2422000: ch = 3; break; \
105 case 2427000: ch = 4; break; \
106 case 2432000: ch = 5; break; \
107 case 2437000: ch = 6; break; \
108 case 2442000: ch = 7; break; \
109 case 2447000: ch = 8; break; \
110 case 2452000: ch = 9; break; \
111 case 2457000: ch = 10; break; \
112 case 2462000: ch = 11; break; \
113 case 2467000: ch = 12; break; \
114 case 2472000: ch = 13; break; \
115 case 2484000: ch = 14; break; \
116 case 5180000: ch = 36; /* UNII */ break; \
117 case 5200000: ch = 40; /* UNII */ break; \
118 case 5220000: ch = 44; /* UNII */ break; \
119 case 5240000: ch = 48; /* UNII */ break; \
120 case 5260000: ch = 52; /* UNII */ break; \
121 case 5280000: ch = 56; /* UNII */ break; \
122 case 5300000: ch = 60; /* UNII */ break; \
123 case 5320000: ch = 64; /* UNII */ break; \
124 case 5745000: ch = 149; /* UNII */ break; \
125 case 5765000: ch = 153; /* UNII */ break; \
126 case 5785000: ch = 157; /* UNII */ break; \
127 case 5805000: ch = 161; /* UNII */ break; \
128 case 5500000: ch = 100; /* HiperLAN2 */ break; \
129 case 5520000: ch = 104; /* HiperLAN2 */ break; \
130 case 5540000: ch = 108; /* HiperLAN2 */ break; \
131 case 5560000: ch = 112; /* HiperLAN2 */ break; \
132 case 5580000: ch = 116; /* HiperLAN2 */ break; \
133 case 5600000: ch = 120; /* HiperLAN2 */ break; \
134 case 5620000: ch = 124; /* HiperLAN2 */ break; \
135 case 5640000: ch = 128; /* HiperLAN2 */ break; \
136 case 5660000: ch = 132; /* HiperLAN2 */ break; \
137 case 5680000: ch = 136; /* HiperLAN2 */ break; \
138 case 5700000: ch = 140; /* HiperLAN2 */ break; \
139 case 5170000: ch = 34; /* Japan MMAC */ break; \
140 case 5190000: ch = 38; /* Japan MMAC */ break; \
141 case 5210000: ch = 42; /* Japan MMAC */ break; \
142 case 5230000: ch = 46; /* Japan MMAC */ break; \
143 default: ch = 1; break; \
147 struct iw_priv_args privtab
[] = {
149 IW_PRIV_TYPE_CHAR
| 1024, 0,
152 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| 1024,
155 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| 1024,
158 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| 1024,
164 int (*set_proc
)(PRTMP_ADAPTER pAdapter
, PUCHAR arg
);
165 } *PRTMP_PRIVATE_SET_PROC
, RTMP_PRIVATE_SUPPORT_PROC
[] = {
166 {"CountryRegion", Set_CountryRegion_Proc
},
167 {"SSID", Set_SSID_Proc
},
168 {"WirelessMode", Set_WirelessMode_Proc
},
169 {"TxRate", Set_TxRate_Proc
},
170 {"AdhocOfdm", Set_AdhocModeRate_Proc
},
171 {"Channel", Set_Channel_Proc
},
172 {"BGProtection", Set_BGProtection_Proc
},
173 {"StaWithEtherBridge", Set_StaWithEtherBridge_Proc
},
174 {"TxPreamble", Set_TxPreamble_Proc
},
175 {"RTSThreshold", Set_RTSThreshold_Proc
},
176 {"FragThreshold", Set_FragThreshold_Proc
},
177 {"TxBurst", Set_TxBurst_Proc
},
178 {"TurboRate", Set_TurboRate_Proc
},
179 {"NetworkType", Set_NetworkType_Proc
},
180 {"AuthMode", Set_AuthMode_Proc
},
181 {"EncrypType", Set_EncrypType_Proc
},
182 {"DefaultKeyID", Set_DefaultKeyID_Proc
},
183 {"Key1", Set_Key1_Proc
},
184 {"Key2", Set_Key2_Proc
},
185 {"Key3", Set_Key3_Proc
},
186 {"Key4", Set_Key4_Proc
},
187 {"WPAPSK", Set_WPAPSK_Proc
},
188 {"WPANONE", Set_WPANONE_Proc
},
190 {"Debug", Set_Debug_Proc
},
194 {"ATE", Set_ATE_Proc
}, // set ATE Mode to: STOP, TXCONT, TXCARR, TXFRAME, RXFRAME
195 {"ATEDA", Set_ATE_DA_Proc
}, // set ATE TxFrames ADDR1, DA
196 {"ATESA", Set_ATE_SA_Proc
}, // set ATE TxFrames ADDR2, SA
197 {"ATEBSSID", Set_ATE_BSSID_Proc
}, // set ATE TxFrames ADDR3, BSSID
198 {"ATECHANNEL",Set_ATE_CHANNEL_Proc
}, // set ATE Channel
199 {"ATETXPOW", Set_ATE_TX_POWER_Proc
}, // set ATE TxPower
200 {"ATETXLEN", Set_ATE_TX_LENGTH_Proc
}, // set ATE TxLength
201 {"ATETXCNT", Set_ATE_TX_COUNT_Proc
}, // set ATE TxCount
202 {"ATETXRATE", Set_ATE_TX_RATE_Proc
}, // set ATE TxRate
203 #endif //#ifdef RALINK_ATE
208 char * rtstrchr(const char * s
, int c
)
210 for(; *s
!= (char) c
; ++s
)
216 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
218 int rt_ioctl_giwrange(struct net_device
*dev
,
219 struct iw_request_info
*info
,
220 struct iw_point
*data
, char *extra
)
222 PRTMP_ADAPTER pAdapter
= (PRTMP_ADAPTER
) dev
->priv
;
223 struct iw_range
*range
= (struct iw_range
*) extra
;
227 //check if the interface is down
228 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
230 DBGPRINT(RT_DEBUG_TRACE
, "INFO::Network is down!\n");
234 DBGPRINT(RT_DEBUG_TRACE
,"0. rtusb_ioctl_giwrange\n");
235 data
->length
= sizeof(struct iw_range
);
236 memset(range
, 0, sizeof(struct iw_range
));
238 range
->txpower_capa
= IW_TXPOW_DBM
;
240 if (INFRA_ON(pAdapter
)||ADHOC_ON(pAdapter
))
242 range
->min_pmp
= 1 * 1024;
243 range
->max_pmp
= 65535 * 1024;
244 range
->min_pmt
= 1 * 1024;
245 range
->max_pmt
= 1000 * 1024;
246 range
->pmp_flags
= IW_POWER_PERIOD
;
247 range
->pmt_flags
= IW_POWER_TIMEOUT
;
248 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
249 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
252 range
->we_version_compiled
= WIRELESS_EXT
;
253 range
->we_version_source
= 14;
255 range
->retry_capa
= IW_RETRY_LIMIT
;
256 range
->retry_flags
= IW_RETRY_LIMIT
;
257 range
->min_retry
= 0;
258 range
->max_retry
= 255;
260 range
->num_channels
= pAdapter
->PortCfg
.ChannelListNum
;
263 for (i
= 0; i
< pAdapter
->PortCfg
.ChannelListNum
; i
++) {
264 range
->freq
[val
].i
=pAdapter
->PortCfg
.ChannelList
[i
];
265 MAP_CHANNEL_ID_TO_KHZ(pAdapter
->PortCfg
.ChannelList
[i
],range
->freq
[val
].m
);
266 range
->freq
[val
].e
= 1;
268 if (val
== IW_MAX_FREQUENCIES
)
271 range
->num_frequency
= val
;
273 range
->max_qual
.qual
= 100; /* what is correct max? This was not
274 * documented exactly. At least
275 * 69 has been observed. */
276 range
->max_qual
.level
= 1; /* dB */
277 range
->max_qual
.noise
= 152; /* dB */
278 range
->max_qual
.updated
= 172; /* Updated all three */
280 /* What would be suitable values for "average/typical" qual? */
281 range
->avg_qual
.qual
= pAdapter
->Mlme
.ChannelQuality
;
282 range
->avg_qual
.level
= pAdapter
->PortCfg
.LastRssi
;
283 range
->avg_qual
.noise
= 0;
284 range
->avg_qual
.updated
= 7; /* Updated all three */
286 range
->sensitivity
= -30;
288 range
->max_encoding_tokens
= NR_WEP_KEYS
;
289 range
->num_encoding_sizes
= 2;
290 range
->encoding_size
[0] = 5;
291 range
->encoding_size
[1] = 13;
293 for (i
= 0; i
< pAdapter
->PortCfg
.SupportedRatesLen
; i
++) {
294 range
->bitrate
[range
->num_bitrates
] =(pAdapter
->PortCfg
.SupportedRates
[i
] & 0x7f)*5000;
295 range
->num_bitrates
++;
297 range
->throughput
= 22000000;
300 len
= prism2_get_datarates(dev
, rates
);
301 range
->num_bitrates
= 0;
302 for (i
= 0; i
< len
; i
++) {
303 if (range
->num_bitrates
< IW_MAX_BITRATES
) {
304 range
->bitrate
[range
->num_bitrates
] =
306 range
->num_bitrates
++;
308 if (rates
[i
] == 0x0b || rates
[i
] == 0x16)
311 /* estimated maximum TCP throughput values (bps) */
312 range
->throughput
= over2
? 5500000 : 1500000;
315 range
->max_rts
= 2347;
316 range
->min_frag
= 256;
317 range
->max_frag
= 2346;
323 rt_ioctl_setparam(struct net_device
*dev
, struct iw_request_info
*info
,
324 void *w
, char *extra
)
326 PRTMP_ADAPTER pAdapter
= (PRTMP_ADAPTER
) dev
->priv
;
331 while ((this_char
= strsep(&extra
, ",")) != NULL
)
336 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
339 if (!value
|| !*value
)
342 for (PRTMP_PRIVATE_SET_PROC
= RTMP_PRIVATE_SUPPORT_PROC
; PRTMP_PRIVATE_SET_PROC
->name
; PRTMP_PRIVATE_SET_PROC
++)
344 if (strcmp(this_char
, PRTMP_PRIVATE_SET_PROC
->name
) == 0)
346 if(!PRTMP_PRIVATE_SET_PROC
->set_proc(pAdapter
, value
))
347 { //FALSE:Set private failed then return Invalid argument
350 break; //Exit for loop.
354 if(PRTMP_PRIVATE_SET_PROC
->name
== NULL
)
355 { //Not found argument
357 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::(iwpriv) Not Support Set Command [%s=%s]\n", this_char
, value
);
364 static const iw_handler rt_priv_handlers
[] = {
365 (iw_handler
) rt_ioctl_setparam
, /* SIOCWFIRSTPRIV+0 */
369 int rt_ioctl_siwscan(struct net_device
*dev
,
370 struct iw_request_info
*info
,
371 struct iw_point
*data
, char *extra
)
374 PRTMP_ADAPTER pAdapter
= (PRTMP_ADAPTER
) dev
->priv
;
375 int Status
= NDIS_STATUS_SUCCESS
;
376 BOOLEAN StateMachineTouched
= FALSE
;
379 //check if the interface is down
380 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
382 DBGPRINT(RT_DEBUG_TRACE
, "INFO::Network is down!\n");
386 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
391 if ((pAdapter
->MediaState
== NdisMediaStateConnected
) &&
392 ((pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPA
) ||
393 (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
)) &&
394 (pAdapter
->PortCfg
.PortSecured
== WPA_802_1X_PORT_NOT_SECURED
)
397 DBGPRINT(RT_DEBUG_TRACE
, "!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n");
398 Status
= NDIS_STATUS_SUCCESS
;
402 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
404 MlmeRestartStateMachine(pAdapter
);
405 DBGPRINT(RT_DEBUG_TRACE
, "!!! MLME busy, reset MLME state machine !!!\n");
408 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
409 // this request, because this request is initiated by NDIS.
410 pAdapter
->Mlme
.CntlAux
.CurrReqIsFromNdis
= FALSE
;
411 // Reset Missed scan number
412 pAdapter
->PortCfg
.IgnoredScanNumber
= 0;
413 pAdapter
->PortCfg
.LastScanTime
= Now
;
415 MlmeEnqueue(&pAdapter
->Mlme
.Queue
,
416 MLME_CNTL_STATE_MACHINE
,
417 OID_802_11_BSSID_LIST_SCAN
,
421 Status
= NDIS_STATUS_SUCCESS
;
422 StateMachineTouched
= TRUE
;
427 rt_ioctl_giwscan(struct net_device
*dev
,
428 struct iw_request_info
*info
,
429 struct iw_point
*data
, char *extra
)
432 PRTMP_ADAPTER pAdapter
= (PRTMP_ADAPTER
) dev
->priv
;
434 char *current_ev
= extra
;
435 char *end_buf
= extra
+ IW_SCAN_MAX_DATA
;
439 //check if the interface is down
440 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
442 DBGPRINT(RT_DEBUG_TRACE
, "INFO::Network is down!\n");
446 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
)){
448 * Still scanning, indicate the caller should try again.
452 for (i
= 0; i
< pAdapter
->PortCfg
.BssTab
.BssNr
; i
++)
454 if (current_ev
>= end_buf
)
457 //================================
458 memset(&iwe
, 0, sizeof(iwe
));
460 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
461 memcpy(iwe
.u
.ap_addr
.sa_data
, &pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Bssid
, ETH_ALEN
);
462 current_ev
= iwe_stream_add_event(current_ev
,end_buf
, &iwe
, IW_EV_ADDR_LEN
);
463 //================================
464 memset(&iwe
, 0, sizeof(iwe
));
465 iwe
.cmd
= SIOCGIWMODE
;
466 if (pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].BssType
== Ndis802_11IBSS
)
468 iwe
.u
.mode
= IW_MODE_ADHOC
;
470 else if (pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].BssType
== Ndis802_11Infrastructure
)
472 iwe
.u
.mode
= IW_MODE_INFRA
;
476 iwe
.u
.mode
= IW_MODE_AUTO
;
479 iwe
.len
= IW_EV_UINT_LEN
;
480 current_ev
= iwe_stream_add_event(current_ev
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
481 //================================
482 memset(&iwe
, 0, sizeof(iwe
));
483 iwe
.cmd
= SIOCGIWESSID
;
484 iwe
.u
.data
.length
= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].SsidLen
;
485 iwe
.u
.data
.flags
= 1;
486 current_ev
= iwe_stream_add_point(current_ev
,end_buf
, &iwe
, pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Ssid
);
487 //================================
488 memset(&iwe
, 0, sizeof(iwe
));
489 iwe
.cmd
= SIOCGIWENCODE
;
490 if (CAP_IS_PRIVACY_ON (pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].CapabilityInfo
))
491 iwe
.u
.data
.flags
=IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
493 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
494 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,&iwe
, pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Ssid
);
496 //================================
497 memset(&iwe
, 0, sizeof(iwe
));
498 iwe
.cmd
= SIOCGIWRATE
;
499 current_val
= current_ev
+ IW_EV_LCP_LEN
;
500 //for (j = 0; j < pAdapter->PortCfg.BssTab.BssEntry[i].RatesLen;j++)
501 for (j
= 0; j
< 1;j
++)
503 iwe
.u
.bitrate
.value
= RateIdToMbps
[pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Rates
[i
]/2] * 1000000;
504 iwe
.u
.bitrate
.disabled
= 0;
505 current_val
= iwe_stream_add_value(current_ev
,
506 current_val
, end_buf
, &iwe
,
509 //================================
510 memset(&iwe
, 0, sizeof(iwe
));
511 iwe
.cmd
= SIOCGIWFREQ
;
512 if (INFRA_ON(pAdapter
) || ADHOC_ON(pAdapter
))
513 iwe
.u
.freq
.m
= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Channel
;
515 iwe
.u
.freq
.m
= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Channel
;
518 current_ev
= iwe_stream_add_event(current_ev
,end_buf
, &iwe
, IW_EV_FREQ_LEN
);
519 //================================
520 memset(&iwe
, 0, sizeof(iwe
));
523 data
->length
= current_ev
- extra
;
524 DBGPRINT(RT_DEBUG_TRACE
,"rtusb_ioctl_giwscan. %d BSS returned\n",pAdapter
->PortCfg
.BssTab
.BssNr
);
528 static const iw_handler rt_handler
[] =
530 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
531 (iw_handler
) NULL
, /* SIOCGIWNAME 1 */
532 (iw_handler
) NULL
, /* SIOCSIWNWID */
533 (iw_handler
) NULL
, /* SIOCGIWNWID */
534 (iw_handler
) NULL
, /* SIOCSIWFREQ */
535 (iw_handler
) NULL
, /* SIOCGIWFREQ 5*/
536 (iw_handler
) NULL
, /* SIOCSIWMODE */
537 (iw_handler
) NULL
, /* SIOCGIWMODE */
538 (iw_handler
) NULL
, /* SIOCSIWSENS */
539 (iw_handler
) NULL
, /* SIOCGIWSENS */
540 (iw_handler
) NULL
/* not used */, /* SIOCSIWRANGE */
541 (iw_handler
) rt_ioctl_giwrange
, /* SIOCGIWRANGE 11 */
542 (iw_handler
) NULL
/* not used */, /* SIOCSIWPRIV */
543 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWPRIV */
544 (iw_handler
) NULL
/* not used */, /* SIOCSIWSTATS */
545 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWSTATS f*/
546 (iw_handler
) NULL
, /* SIOCSIWSPY */
547 (iw_handler
) NULL
, /* SIOCGIWSPY */
548 (iw_handler
) NULL
, /* -- hole -- */
549 (iw_handler
) NULL
, /* -- hole -- */
550 (iw_handler
) NULL
, /* SIOCSIWAP */
551 (iw_handler
) NULL
, /* SIOCGIWAP 0x15*/
552 (iw_handler
) NULL
, /* -- hole -- 0x16 */
553 (iw_handler
) NULL
, /* SIOCGIWAPLIST */
555 (iw_handler
) rt_ioctl_siwscan
, /* SIOCSIWSCAN 0x18*/
556 (iw_handler
) rt_ioctl_giwscan
, /* SIOCGIWSCAN */
558 (iw_handler
) NULL
, /* SIOCSIWSCAN */
559 (iw_handler
) NULL
, /* SIOCGIWSCAN */
560 #endif /* SIOCGIWSCAN */
561 (iw_handler
) NULL
, /* SIOCSIWESSID */
562 (iw_handler
) NULL
, /* SIOCGIWESSID */
563 (iw_handler
) NULL
, /* SIOCSIWNICKN */
564 (iw_handler
) NULL
, /* SIOCGIWNICKN 1d*/
565 (iw_handler
) NULL
, /* -- hole -- */
566 (iw_handler
) NULL
, /* -- hole -- */
567 (iw_handler
) NULL
, /* SIOCSIWRATE 20*/
568 (iw_handler
) NULL
, /* SIOCGIWRATE */
569 (iw_handler
) NULL
, /* SIOCSIWRTS */
570 (iw_handler
) NULL
, /* SIOCGIWRTS */
571 (iw_handler
) NULL
, /* SIOCSIWFRAG */
572 (iw_handler
) NULL
, /* SIOCGIWFRAG 25*/
573 (iw_handler
) NULL
, /* SIOCSIWTXPOW */
574 (iw_handler
) NULL
, /* SIOCGIWTXPOW */
575 (iw_handler
) NULL
, /* SIOCSIWRETRY */
576 (iw_handler
) NULL
, /* SIOCGIWRETRY 29*/
577 (iw_handler
) NULL
, /* SIOCSIWENCODE 2a*/
578 (iw_handler
) NULL
, /* SIOCGIWENCODE 2b*/
579 (iw_handler
) NULL
, /* SIOCSIWPOWER 2c*/
580 (iw_handler
) NULL
, /* SIOCGIWPOWER 2d*/
583 const struct iw_handler_def rt2500_iw_handler_def
=
585 #define N(a) (sizeof (a) / sizeof (a[0]))
586 .standard
= (iw_handler
*) rt_handler
,
587 .num_standard
= sizeof(rt_handler
) / sizeof(iw_handler
),
588 .private = (iw_handler
*) rt_priv_handlers
,
589 .num_private
= N(rt_priv_handlers
),
590 .private_args
= (struct iw_priv_args
*) privtab
,
591 .num_private_args
= N(privtab
),
592 #if WIRELESS_EXT > 15
593 // .spy_offset = offsetof(struct hostap_interface, spy_data),
594 #endif /* WIRELESS_EXT > 15 */
596 INT
RTMPSetInformation(
597 IN PRTMP_ADAPTER pAdapter
,
598 IN OUT
struct ifreq
*rq
,
601 struct iwreq
*wrq
= (struct iwreq
*) rq
;
602 NDIS_802_11_SSID Ssid
, *pSsid
=NULL
;
603 NDIS_802_11_MAC_ADDRESS Bssid
;
604 RT_802_11_PHY_MODE PhyMode
;
605 RT_802_11_STA_CONFIG StaConfig
;
606 NDIS_802_11_RATES aryRates
;
607 RT_802_11_PREAMBLE Preamble
;
608 NDIS_802_11_WEP_STATUS WepStatus
;
609 NDIS_802_11_AUTHENTICATION_MODE AuthMode
;
610 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType
;
611 NDIS_802_11_RTS_THRESHOLD RtsThresh
;
612 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh
;
613 NDIS_802_11_POWER_MODE PowerMode
;
614 NDIS_802_11_TX_POWER_LEVEL TxPowerLevel
;
615 PNDIS_802_11_KEY pKey
= NULL
;
616 PNDIS_802_11_REMOVE_KEY pRemoveKey
= NULL
;
617 NDIS_802_11_CONFIGURATION Config
, *pConfig
= NULL
;
620 INT Status
= NDIS_STATUS_SUCCESS
;
623 BOOLEAN StateMachineTouched
= FALSE
;
626 switch(cmd
& 0x7FFF) {
627 case RT_OID_802_11_COUNTRY_REGION
:
628 if (wrq
->u
.data
.length
!= sizeof(CountryRegion
))
632 Status
= copy_from_user(&CountryRegion
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
633 pAdapter
->PortCfg
.CountryRegion
= CountryRegion
;
634 DBGPRINT(RT_DEBUG_TRACE
, "Set::RT_OID_802_11_COUNTRY_REGION (=%d) \n", pAdapter
->PortCfg
.CountryRegion
);
637 case OID_802_11_BSSID_LIST_SCAN
:
639 TxTotalCnt
= pAdapter
->DrsCounters
.OneSecTxOkCount
+
640 pAdapter
->DrsCounters
.OneSecTxRetryOkCount
+
641 pAdapter
->DrsCounters
.OneSecTxFailCount
;
642 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", TxTotalCnt
);
643 // For XP WZC, we will allow scan every 10 times, roughly 10 minutes.
644 // if ((Oid == OID_802_11_BSSID_LIST_SCAN) &&
645 // (pAdapter->MediaState == NdisMediaStateConnected) &&
646 // (pAdapter->PortCfg.IgnoredScanNumber < 10))
647 if (TxTotalCnt
> 100)
649 DBGPRINT(RT_DEBUG_TRACE
, "!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n");
650 Status
= NDIS_STATUS_SUCCESS
;
651 pAdapter
->PortCfg
.IgnoredScanNumber
++;
655 if ((pAdapter
->MediaState
== NdisMediaStateConnected
) &&
656 ((pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPA
) ||
657 (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
)) &&
658 (pAdapter
->PortCfg
.PortSecured
== WPA_802_1X_PORT_NOT_SECURED
)
661 DBGPRINT(RT_DEBUG_TRACE
, "!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n");
662 Status
= NDIS_STATUS_SUCCESS
;
666 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
668 MlmeRestartStateMachine(pAdapter
);
669 DBGPRINT(RT_DEBUG_TRACE
, "!!! MLME busy, reset MLME state machine !!!\n");
672 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
673 // this request, because this request is initiated by NDIS.
674 pAdapter
->Mlme
.CntlAux
.CurrReqIsFromNdis
= FALSE
;
675 // Reset Missed scan number
676 pAdapter
->PortCfg
.IgnoredScanNumber
= 0;
677 pAdapter
->PortCfg
.LastScanTime
= Now
;
679 MlmeEnqueue(&pAdapter
->Mlme
.Queue
,
680 MLME_CNTL_STATE_MACHINE
,
681 OID_802_11_BSSID_LIST_SCAN
,
685 Status
= NDIS_STATUS_SUCCESS
;
686 StateMachineTouched
= TRUE
;
688 case OID_802_11_SSID
:
689 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_SSID
))
693 Status
= copy_from_user(&Ssid
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
696 if (pSsid
->SsidLength
> MAX_LEN_OF_SSID
)
700 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
702 MlmeRestartStateMachine(pAdapter
);
703 DBGPRINT(RT_DEBUG_TRACE
, "!!! MLME busy, reset MLME state machine !!!\n");
705 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
706 // this request, because this request is initiated by NDIS.
707 pAdapter
->Mlme
.CntlAux
.CurrReqIsFromNdis
= FALSE
;
709 MlmeEnqueue(&pAdapter
->Mlme
.Queue
,
710 MLME_CNTL_STATE_MACHINE
,
712 sizeof(NDIS_802_11_SSID
),
715 Status
= NDIS_STATUS_SUCCESS
;
716 StateMachineTouched
= TRUE
;
718 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", pSsid
->SsidLength
, pSsid
->Ssid
);
722 case OID_802_11_BSSID
:
723 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_MAC_ADDRESS
))
727 Status
= copy_from_user(&Bssid
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
729 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
731 MlmeRestartStateMachine(pAdapter
);
732 DBGPRINT(RT_DEBUG_TRACE
, "!!! MLME busy, reset MLME state machine !!!\n");
735 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
736 // this request, because this request is initiated by NDIS.
737 pAdapter
->Mlme
.CntlAux
.CurrReqIsFromNdis
= FALSE
;
739 MlmeEnqueue(&pAdapter
->Mlme
.Queue
,
740 MLME_CNTL_STATE_MACHINE
,
742 sizeof(NDIS_802_11_MAC_ADDRESS
),
744 Status
= NDIS_STATUS_SUCCESS
;
745 StateMachineTouched
= TRUE
;
746 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
747 Bssid
[0], Bssid
[1], Bssid
[2], Bssid
[3], Bssid
[4], Bssid
[5]);
750 case RT_OID_802_11_RADIO
:
751 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
755 Status
= copy_from_user(&RadioState
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
756 DBGPRINT(RT_DEBUG_TRACE
, "Set::RT_OID_802_11_RADIO (=%d)\n", RadioState
);
757 if (pAdapter
->PortCfg
.bSwRadio
!= RadioState
)
759 pAdapter
->PortCfg
.bSwRadio
= RadioState
;
760 if (pAdapter
->PortCfg
.bRadio
!= (pAdapter
->PortCfg
.bHwRadio
&& pAdapter
->PortCfg
.bSwRadio
))
762 pAdapter
->PortCfg
.bRadio
= (pAdapter
->PortCfg
.bHwRadio
&& pAdapter
->PortCfg
.bSwRadio
);
763 if (pAdapter
->PortCfg
.bRadio
== TRUE
)
764 MlmeRadioOn(pAdapter
);
766 MlmeRadioOff(pAdapter
);
771 case RT_OID_802_11_PHY_MODE
:
772 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_PHY_MODE
))
776 Status
= copy_from_user(&PhyMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
777 RTMPSetPhyMode(pAdapter
, PhyMode
);
778 DBGPRINT(RT_DEBUG_TRACE
, "Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode
);
781 case RT_OID_802_11_STA_CONFIG
:
782 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_STA_CONFIG
))
786 Status
= copy_from_user(&StaConfig
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
787 pAdapter
->PortCfg
.EnableTxBurst
= StaConfig
.EnableTxBurst
;
788 pAdapter
->PortCfg
.EnableTurboRate
= StaConfig
.EnableTurboRate
;
789 pAdapter
->PortCfg
.UseBGProtection
= StaConfig
.UseBGProtection
;
790 // pAdapter->PortCfg.UseShortSlotTime = StaConfig.UseShortSlotTime;
791 pAdapter
->PortCfg
.UseShortSlotTime
= 1; // 2003-10-30 always SHORT SLOT capable
792 if (pAdapter
->PortCfg
.AdhocMode
!= StaConfig
.AdhocMode
)
794 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
795 // if setting changed, need to reset current TX rate as well as BEACON frame format
796 pAdapter
->PortCfg
.AdhocMode
= StaConfig
.AdhocMode
;
797 if (pAdapter
->PortCfg
.BssType
== BSS_INDEP
)
799 MlmeUpdateTxRates(pAdapter
, FALSE
);
800 MakeIbssBeacon(pAdapter
);
803 DBGPRINT(RT_DEBUG_TRACE
, "Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d,72/100=%d,Protection=%d,ShortSlot=%d,OFDM in 11g Adhoc=%d\n",
804 pAdapter
->PortCfg
.EnableTxBurst
,
805 pAdapter
->PortCfg
.EnableTurboRate
,
806 pAdapter
->PortCfg
.UseBGProtection
,
807 pAdapter
->PortCfg
.UseShortSlotTime
,
808 pAdapter
->PortCfg
.AdhocMode
);
811 case OID_802_11_DESIRED_RATES
:
812 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_RATES
))
816 Status
= copy_from_user(&aryRates
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
817 NdisZeroMemory(pAdapter
->PortCfg
.DesiredRates
, MAX_LEN_OF_SUPPORTED_RATES
);
818 NdisMoveMemory(pAdapter
->PortCfg
.DesiredRates
, &aryRates
, sizeof(NDIS_802_11_RATES
));
819 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
820 pAdapter
->PortCfg
.DesiredRates
[0],pAdapter
->PortCfg
.DesiredRates
[1],
821 pAdapter
->PortCfg
.DesiredRates
[2],pAdapter
->PortCfg
.DesiredRates
[3],
822 pAdapter
->PortCfg
.DesiredRates
[4],pAdapter
->PortCfg
.DesiredRates
[5],
823 pAdapter
->PortCfg
.DesiredRates
[6],pAdapter
->PortCfg
.DesiredRates
[7] );
824 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
825 MlmeUpdateTxRates(pAdapter
, FALSE
);
828 case RT_OID_802_11_PREAMBLE
:
829 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_PREAMBLE
))
833 Status
= copy_from_user(&Preamble
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
834 if (Preamble
== Rt802_11PreambleShort
)
836 pAdapter
->PortCfg
.WindowsTxPreamble
= Preamble
;
837 MlmeSetTxPreamble(pAdapter
, Rt802_11PreambleShort
);
839 else if ((Preamble
== Rt802_11PreambleLong
) || (Preamble
== Rt802_11PreambleAuto
))
841 // if user wants AUTO, initialize to LONG here, then change according to AP's
842 // capability upon association.
843 pAdapter
->PortCfg
.WindowsTxPreamble
= Preamble
;
844 MlmeSetTxPreamble(pAdapter
, Rt802_11PreambleLong
);
851 DBGPRINT(RT_DEBUG_TRACE
, "Set::RT_OID_802_11_SET_PREAMBLE (=%d)\n", Preamble
);
854 case OID_802_11_WEP_STATUS
:
855 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_WEP_STATUS
))
859 Status
= copy_from_user(&WepStatus
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
860 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
861 if (WepStatus
<= Ndis802_11Encryption3KeyAbsent
)
863 if (pAdapter
->PortCfg
.WepStatus
!= WepStatus
)
865 // Config has changed
866 pAdapter
->bConfigChanged
= TRUE
;
868 pAdapter
->PortCfg
.WepStatus
= WepStatus
;
875 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus
);
878 case OID_802_11_AUTHENTICATION_MODE
:
879 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_AUTHENTICATION_MODE
))
883 Status
= copy_from_user(&AuthMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
884 if (AuthMode
> Ndis802_11AuthModeMax
)
891 if (pAdapter
->PortCfg
.AuthMode
!= AuthMode
)
893 // Config has changed
894 pAdapter
->bConfigChanged
= TRUE
;
896 pAdapter
->PortCfg
.AuthMode
= AuthMode
;
898 pAdapter
->PortCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
899 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter
->PortCfg
.AuthMode
);
902 case OID_802_11_INFRASTRUCTURE_MODE
:
903 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE
))
907 Status
= copy_from_user(&BssType
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
908 if (BssType
== Ndis802_11IBSS
)
910 if (pAdapter
->PortCfg
.BssType
!= BSS_INDEP
)
912 // Config has changed
913 pAdapter
->bConfigChanged
= TRUE
;
915 pAdapter
->PortCfg
.BssType
= BSS_INDEP
;
916 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_INFRASTRUCTURE_MODE (AD-HOC)\n");
918 else if (BssType
== Ndis802_11Infrastructure
)
920 if (pAdapter
->PortCfg
.BssType
!= BSS_INFRA
)
922 // Config has changed
923 pAdapter
->bConfigChanged
= TRUE
;
925 pAdapter
->PortCfg
.BssType
= BSS_INFRA
;
926 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_INFRASTRUCTURE_MODE (INFRA)\n");
931 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n");
934 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
935 pAdapter
->PortCfg
.WpaState
= SS_NOTUSE
;
937 case RT_OID_802_11_RESET_COUNTERS
:
938 NdisZeroMemory(&pAdapter
->WlanCounters
, sizeof(COUNTER_802_11
));
939 NdisZeroMemory(&pAdapter
->Counters
, sizeof(COUNTER_802_3
));
940 NdisZeroMemory(&pAdapter
->RalinkCounters
, sizeof(COUNTER_RALINK
));
941 NdisZeroMemory(&pAdapter
->Mlme
.PrevWlanCounters
, sizeof(COUNTER_802_11
));
942 DBGPRINT(RT_DEBUG_INFO
, "Set::RT_OID_802_11_RESET_COUNTERS \n");
944 case OID_802_11_RTS_THRESHOLD
:
945 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_RTS_THRESHOLD
))
949 Status
= copy_from_user(&RtsThresh
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
950 if (RtsThresh
> MAX_RTS_THRESHOLD
)
953 pAdapter
->PortCfg
.RtsThreshold
= (USHORT
)RtsThresh
;
955 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_RTS_THRESHOLD (=%d)\n",RtsThresh
);
957 case OID_802_11_FRAGMENTATION_THRESHOLD
:
958 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD
))
962 Status
= copy_from_user(&FragThresh
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
963 pAdapter
->PortCfg
.bFragmentZeroDisable
= FALSE
;
964 if (FragThresh
> MAX_FRAG_THRESHOLD
|| FragThresh
< MIN_FRAG_THRESHOLD
)
968 pAdapter
->PortCfg
.FragmentThreshold
= MAX_FRAG_THRESHOLD
;
969 pAdapter
->PortCfg
.bFragmentZeroDisable
= TRUE
;
975 pAdapter
->PortCfg
.FragmentThreshold
= (USHORT
)FragThresh
;
977 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%d) \n",FragThresh
);
979 case OID_802_11_POWER_MODE
:
980 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_POWER_MODE
))
984 Status
= copy_from_user(&PowerMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
985 // save user's policy here, but not change PortCfg.Psm immediately
986 if (PowerMode
== Ndis802_11PowerModeCAM
)
988 // clear PSM bit immediately
989 MlmeSetPsmBit(pAdapter
, PWR_ACTIVE
);
990 pAdapter
->PortCfg
.RecvDtim
= TRUE
;
991 if (pAdapter
->PortCfg
.WindowsACCAMEnable
== FALSE
)
992 pAdapter
->PortCfg
.WindowsPowerMode
= PowerMode
;
993 pAdapter
->PortCfg
.WindowsBatteryPowerMode
= PowerMode
;
995 else if (PowerMode
== Ndis802_11PowerModeMAX_PSP
)
997 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
998 // to exclude certain situations.
999 // MlmeSetPsmBit(pAdapter, PWR_SAVE);
1000 if (pAdapter
->PortCfg
.WindowsACCAMEnable
== FALSE
)
1001 pAdapter
->PortCfg
.WindowsPowerMode
= PowerMode
;
1002 pAdapter
->PortCfg
.WindowsBatteryPowerMode
= PowerMode
;
1003 pAdapter
->PortCfg
.RecvDtim
= TRUE
; // FALSE;
1004 pAdapter
->PortCfg
.DefaultListenCount
= 5;
1006 else if (PowerMode
== Ndis802_11PowerModeFast_PSP
)
1008 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
1009 // to exclude certain situations.
1010 // MlmeSetPsmBit(pAdapter, PWR_SAVE);
1011 pAdapter
->PortCfg
.RecvDtim
= TRUE
;
1012 if (pAdapter
->PortCfg
.WindowsACCAMEnable
== FALSE
)
1013 pAdapter
->PortCfg
.WindowsPowerMode
= PowerMode
;
1014 pAdapter
->PortCfg
.WindowsBatteryPowerMode
= PowerMode
;
1015 pAdapter
->PortCfg
.DefaultListenCount
= 3;
1020 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode
);
1022 case OID_802_11_TX_POWER_LEVEL
:
1023 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_TX_POWER_LEVEL
))
1027 Status
= copy_from_user(&TxPowerLevel
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
1028 if (TxPowerLevel
> MAX_TX_POWER_LEVEL
)
1031 pAdapter
->PortCfg
.TxPower
= (UCHAR
)TxPowerLevel
;
1033 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_TX_POWER_LEVEL (=%d) \n",TxPowerLevel
);
1035 // For WPA PSK PMK key
1036 case RT_OID_802_11_ADD_WPA
:
1037 pKey
= kmalloc(wrq
->u
.data
.length
, GFP_KERNEL
);
1044 Status
= copy_from_user(pKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
1045 if (pKey
->Length
!= wrq
->u
.data
.length
)
1048 DBGPRINT(RT_DEBUG_TRACE
, "Set::RT_OID_802_11_ADD_WPA, Failed!!\n");
1052 if (pAdapter
->PortCfg
.AuthMode
!= Ndis802_11AuthModeWPAPSK
)
1054 Status
= -EOPNOTSUPP
;
1055 DBGPRINT(RT_DEBUG_TRACE
, "Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK]\n");
1057 else // Only for WPA PSK mode
1059 pAdapter
->PortCfg
.PskKey
.KeyLen
= (UCHAR
) pKey
->KeyLength
;
1060 NdisMoveMemory(pAdapter
->PortCfg
.PskKey
.Key
, &pKey
->KeyMaterial
, pKey
->KeyLength
);
1061 // Use RaConfig as PSK agent.
1062 // Start STA supplicant state machine
1063 pAdapter
->PortCfg
.WpaState
= SS_START
;
1065 DBGPRINT(RT_DEBUG_TRACE
, "Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey
->KeyIndex
, pKey
->KeyLength
);
1070 case OID_802_11_REMOVE_KEY
:
1071 pRemoveKey
= kmalloc(wrq
->u
.data
.length
, GFP_KERNEL
);
1072 if(pRemoveKey
== NULL
)
1078 Status
= copy_from_user(pRemoveKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
1079 if (pRemoveKey
->Length
!= wrq
->u
.data
.length
)
1082 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_REMOVE_KEY, Failed!!\n");
1086 if (pAdapter
->PortCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
1088 RTMPWPARemoveKeyProc(pAdapter
, pRemoveKey
);
1089 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n");
1093 KeyIdx
= pRemoveKey
->KeyIndex
;
1095 if (KeyIdx
& 0x80000000)
1097 // Should never set default bit when remove key
1099 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n");
1103 KeyIdx
= KeyIdx
& 0x0fffffff;
1107 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx
);
1111 pAdapter
->PortCfg
.SharedKey
[KeyIdx
].KeyLen
= 0;
1112 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey
->KeyIndex
, pRemoveKey
->Length
);
1119 case OID_802_11_ADD_KEY
:
1120 pKey
= kmalloc(wrq
->u
.data
.length
, GFP_KERNEL
);
1127 Status
= copy_from_user(pKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
1128 if (pKey
->Length
!= wrq
->u
.data
.length
)
1131 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_ADD_KEY, Failed!!\n");
1135 if (pAdapter
->PortCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
1137 RTMPWPAAddKeyProc(pAdapter
, pKey
);
1139 else // Old WEP stuff
1141 KeyIdx
= pKey
->KeyIndex
& 0x0fffffff;
1143 // it is a shared key
1148 pAdapter
->PortCfg
.SharedKey
[KeyIdx
].KeyLen
= (UCHAR
) pKey
->KeyLength
;
1149 NdisMoveMemory(pAdapter
->PortCfg
.SharedKey
[KeyIdx
].Key
, &pKey
->KeyMaterial
, pKey
->KeyLength
);
1150 if (pKey
->KeyIndex
& 0x80000000)
1152 // Default key for tx (shared key)
1153 pAdapter
->PortCfg
.DefaultKeyId
= (UCHAR
) KeyIdx
;
1157 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey
->KeyIndex
, pKey
->KeyLength
);
1161 case OID_802_11_CONFIGURATION
:
1162 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_CONFIGURATION
))
1166 Status
= copy_from_user(&Config
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
1168 pAdapter
->PortCfg
.IbssConfig
.BeaconPeriod
= (USHORT
) pConfig
->BeaconPeriod
;
1169 pAdapter
->PortCfg
.IbssConfig
.AtimWin
= (USHORT
) pConfig
->ATIMWindow
;
1170 MAP_KHZ_TO_CHANNEL_ID(pConfig
->DSConfig
, pAdapter
->PortCfg
.IbssConfig
.Channel
);
1171 DBGPRINT(RT_DEBUG_TRACE
, "Set::OID_802_11_CONFIGURATION (BeacnPeriod=%d,AtimW=%d,Ch=%d)\n",
1172 pConfig
->BeaconPeriod
, pConfig
->ATIMWindow
, pAdapter
->PortCfg
.IbssConfig
.Channel
);
1173 // Config has changed
1174 pAdapter
->bConfigChanged
= TRUE
;
1178 DBGPRINT(RT_DEBUG_TRACE
, "Set::unknown IOCTL's subcmd = 0x%08x\n", cmd
);
1179 Status
= -EOPNOTSUPP
;
1186 INT
RTMPQueryInformation(
1187 IN PRTMP_ADAPTER pAdapter
,
1188 IN OUT
struct ifreq
*rq
,
1191 struct iwreq
*wrq
= (struct iwreq
*) rq
;
1192 NDIS_802_11_BSSID_LIST_EX
*pBssidList
= NULL
;
1193 PNDIS_WLAN_BSSID_EX pBss
;
1194 NDIS_802_11_SSID Ssid
;
1195 NDIS_802_11_CONFIGURATION Configuration
;
1196 RT_802_11_LINK_STATUS LinkStatus
;
1197 RT_802_11_STA_CONFIG StaConfig
;
1198 NDIS_802_11_STATISTICS Statistics
;
1199 NDIS_802_11_RTS_THRESHOLD RtsThresh
;
1200 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh
;
1201 NDIS_802_11_POWER_MODE PowerMode
;
1202 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType
;
1203 RT_802_11_PREAMBLE PreamType
;
1204 NDIS_802_11_AUTHENTICATION_MODE AuthMode
;
1205 NDIS_802_11_WEP_STATUS WepStatus
;
1206 RT_VERSION_INFO DriverVersionInfo
;
1213 INT Status
= NDIS_STATUS_SUCCESS
;
1219 case RT_OID_DEVICE_NAME
:
1220 DBGPRINT(RT_DEBUG_TRACE
, "Query::RT_OID_DEVICE_NAME\n");
1221 wrq
->u
.data
.length
= sizeof(NIC_DEVICE_NAME
);
1222 Status
= copy_to_user(wrq
->u
.data
.pointer
, NIC_DEVICE_NAME
, wrq
->u
.data
.length
);
1224 case RT_OID_VERSION_INFO
:
1225 DBGPRINT(RT_DEBUG_INFO
, "Query::RT_OID_VERSION_INFO \n");
1226 DriverVersionInfo
.DriverVersionW
= DRV_MAJORVERSION
;
1227 DriverVersionInfo
.DriverVersionX
= DRV_MINORVERSION
;
1228 DriverVersionInfo
.DriverVersionY
= DRV_SUBVERSION
;
1229 DriverVersionInfo
.DriverVersionZ
= DRV_TESTVERSION
;
1230 DriverVersionInfo
.DriverBuildYear
= DRV_YEAR
;
1231 DriverVersionInfo
.DriverBuildMonth
= DRV_MONTH
;
1232 DriverVersionInfo
.DriverBuildDay
= DRV_DAY
;
1233 wrq
->u
.data
.length
= sizeof(RT_VERSION_INFO
);
1234 Status
= copy_to_user(wrq
->u
.data
.pointer
, &DriverVersionInfo
, wrq
->u
.data
.length
);
1236 case OID_802_11_BSSID_LIST
:
1237 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter
->PortCfg
.BssTab
.BssNr
);
1238 // Claculate total buffer size required
1239 BssBufSize
= sizeof(ULONG
);
1241 for (i
= 0; i
< pAdapter
->PortCfg
.BssTab
.BssNr
; i
++)
1243 // Align pointer to 4 bytes boundary.
1244 Padding
= 4 - (pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIELen
& 0x0003);
1247 BssBufSize
+= (sizeof(NDIS_WLAN_BSSID_EX
) - 4 + sizeof(NDIS_802_11_FIXED_IEs
) + pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIELen
+ Padding
);
1250 // For safety issue, we add 256 bytes just in case
1252 // Allocate the same size as passed from higher layer
1253 pBuf
= kmalloc(BssBufSize
, GFP_KERNEL
);
1259 // Init 802_11_BSSID_LIST_EX structure
1260 NdisZeroMemory(pBuf
, BssBufSize
);
1261 pBssidList
= (PNDIS_802_11_BSSID_LIST_EX
) pBuf
;
1262 pBssidList
->NumberOfItems
= pAdapter
->PortCfg
.BssTab
.BssNr
;
1264 // Calculate total buffer length
1265 BssLen
= 4; // Consist of NumberOfItems
1266 // Point to start of NDIS_WLAN_BSSID_EX
1267 // pPtr = pBuf + sizeof(ULONG);
1268 pPtr
= (PUCHAR
) &pBssidList
->Bssid
[0];
1269 for (i
= 0; i
< pAdapter
->PortCfg
.BssTab
.BssNr
; i
++)
1271 pBss
= (PNDIS_WLAN_BSSID_EX
) pPtr
;
1272 NdisMoveMemory(&pBss
->MacAddress
, &pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Bssid
, MAC_ADDR_LEN
);
1273 if ((pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Hidden
== 1) && (pAdapter
->PortCfg
.bShowHiddenSSID
== FALSE
))
1275 pBss
->Ssid
.SsidLength
= 0;
1279 pBss
->Ssid
.SsidLength
= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].SsidLen
;
1280 NdisMoveMemory(pBss
->Ssid
.Ssid
, pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Ssid
, pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].SsidLen
);
1282 pBss
->Privacy
= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Privacy
;
1283 pBss
->Rssi
= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Rssi
- pAdapter
->PortCfg
.RssiToDbm
;
1284 pBss
->NetworkTypeInUse
= Ndis802_11DS
;
1285 pBss
->Configuration
.Length
= sizeof(NDIS_802_11_CONFIGURATION
);
1286 pBss
->Configuration
.BeaconPeriod
= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].BeaconPeriod
;
1287 pBss
->Configuration
.ATIMWindow
= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].AtimWin
;
1289 MAP_CHANNEL_ID_TO_KHZ(pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Channel
, pBss
->Configuration
.DSConfig
);
1291 if (pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].BssType
== BSS_INFRA
)
1292 pBss
->InfrastructureMode
= Ndis802_11Infrastructure
;
1294 pBss
->InfrastructureMode
= Ndis802_11IBSS
;
1296 NdisMoveMemory(pBss
->SupportedRates
, pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Rates
, pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].RatesLen
);
1298 DBGPRINT(RT_DEBUG_TRACE
, "BSS#%d - %s, Ch %d = %d Khz\n",
1299 i
,pBss
->Ssid
.Ssid
,pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].Channel
,pBss
->Configuration
.DSConfig
);
1301 if (pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIELen
== 0)
1303 pBss
->IELength
= sizeof(NDIS_802_11_FIXED_IEs
);
1304 NdisMoveMemory(pBss
->IEs
, &pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].FixIEs
, sizeof(NDIS_802_11_FIXED_IEs
));
1305 pPtr
= pPtr
+ sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
);
1309 pBss
->IELength
= sizeof(NDIS_802_11_FIXED_IEs
) + pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIELen
;
1310 pPtr
= pPtr
+ sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
);
1311 NdisMoveMemory(pBss
->IEs
, &pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].FixIEs
, sizeof(NDIS_802_11_FIXED_IEs
));
1312 NdisMoveMemory(pPtr
, pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIEs
, pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIELen
);
1313 pPtr
+= pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIELen
;
1315 // Align pointer to 4 bytes boundary.
1316 Padding
= 4 - (pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIELen
& 0x0003);
1320 pBss
->Length
= sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
) + pAdapter
->PortCfg
.BssTab
.BssEntry
[i
].VarIELen
+ Padding
;
1321 BssLen
+= pBss
->Length
;
1323 wrq
->u
.data
.length
= BssLen
;
1324 Status
= copy_to_user(wrq
->u
.data
.pointer
, pBssidList
, wrq
->u
.data
.length
);
1327 case OID_802_3_CURRENT_ADDRESS
:
1328 wrq
->u
.data
.length
= ETH_LENGTH_OF_ADDRESS
;
1329 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->CurrentAddress
, wrq
->u
.data
.length
);
1330 DBGPRINT(RT_DEBUG_INFO
, "Query::OID_802_3_CURRENT_ADDRESS \n");
1332 case OID_GEN_MEDIA_CONNECT_STATUS
:
1333 DBGPRINT(RT_DEBUG_INFO
, "Query::OID_GEN_MEDIA_CONNECT_STATUS \n");
1334 wrq
->u
.data
.length
= sizeof(NDIS_MEDIA_STATE
);
1335 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->MediaState
, wrq
->u
.data
.length
);
1337 case OID_802_11_BSSID
:
1338 if (INFRA_ON(pAdapter
) || ADHOC_ON(pAdapter
))
1340 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->PortCfg
.Bssid
, sizeof(MACADDR
));
1342 DBGPRINT(RT_DEBUG_INFO
, "IOCTL::SIOCGIWAP(=%02x:%02x:%02x:%02x:%02x:%02x)\n",
1343 pAdapter
->PortCfg
.Bssid
.Octet
[0],pAdapter
->PortCfg
.Bssid
.Octet
[1],pAdapter
->PortCfg
.Bssid
.Octet
[2],
1344 pAdapter
->PortCfg
.Bssid
.Octet
[3],pAdapter
->PortCfg
.Bssid
.Octet
[4],pAdapter
->PortCfg
.Bssid
.Octet
[5]);
1349 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_BSSID(=EMPTY)\n");
1353 case OID_802_11_SSID
:
1354 Ssid
.SsidLength
= pAdapter
->PortCfg
.SsidLen
;
1355 NdisZeroMemory(Ssid
.Ssid
, MAX_LEN_OF_SSID
);
1356 NdisMoveMemory(Ssid
.Ssid
, pAdapter
->PortCfg
.Ssid
, Ssid
.SsidLength
);
1357 wrq
->u
.data
.length
= sizeof(NDIS_802_11_SSID
);
1358 Status
= copy_to_user(wrq
->u
.data
.pointer
, &Ssid
, wrq
->u
.data
.length
);
1359 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid
.SsidLength
,Ssid
.Ssid
);
1361 case RT_OID_802_11_LINK_STATUS
:
1362 LinkStatus
.CurrTxRate
= RateIdTo500Kbps
[pAdapter
->PortCfg
.TxRate
]; // unit : 500 kbps
1363 LinkStatus
.ChannelQuality
= pAdapter
->Mlme
.ChannelQuality
;
1364 LinkStatus
.RxByteCount
= pAdapter
->RalinkCounters
.ReceivedByteCount
;
1365 LinkStatus
.TxByteCount
= pAdapter
->RalinkCounters
.TransmittedByteCount
;
1366 wrq
->u
.data
.length
= sizeof(RT_802_11_LINK_STATUS
);
1367 Status
= copy_to_user(wrq
->u
.data
.pointer
, &LinkStatus
, wrq
->u
.data
.length
);
1368 DBGPRINT(RT_DEBUG_TRACE
, "Query::RT_OID_802_11_LINK_STATUS\n");
1370 case OID_802_11_CONFIGURATION
:
1371 Configuration
.Length
= sizeof(NDIS_802_11_CONFIGURATION
);
1372 Configuration
.BeaconPeriod
= pAdapter
->PortCfg
.BeaconPeriod
;
1373 Configuration
.ATIMWindow
= pAdapter
->PortCfg
.AtimWin
;
1374 MAP_CHANNEL_ID_TO_KHZ(pAdapter
->PortCfg
.Channel
, Configuration
.DSConfig
);
1375 wrq
->u
.data
.length
= sizeof(NDIS_802_11_CONFIGURATION
);
1376 Status
= copy_to_user(wrq
->u
.data
.pointer
, &Configuration
, wrq
->u
.data
.length
);
1377 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_CONFIGURATION(BeaconPeriod=%d,AtimW=%d,Channel=%d) \n",
1378 Configuration
.BeaconPeriod
, Configuration
.ATIMWindow
, pAdapter
->PortCfg
.Channel
);
1380 case OID_802_11_RSSI
:
1381 ulInfo
= pAdapter
->PortCfg
.LastRssi
- pAdapter
->PortCfg
.RssiToDbm
;
1382 wrq
->u
.data
.length
= sizeof(ulInfo
);
1383 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
1384 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_RSSI(=%d)\n", ulInfo
);
1386 case OID_802_11_STATISTICS
:
1387 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_STATISTICS \n");
1388 // Update FCS counters
1389 RTMP_IO_READ32(pAdapter
, CNT0
, &FcsValue
);
1390 pAdapter
->WlanCounters
.FCSErrorCount
.QuadPart
+= ((FcsValue
& 0x0000ffff) >> 7);
1391 // Add FCS error count to private counters
1392 pAdapter
->RalinkCounters
.RealFcsErrCount
.QuadPart
+= FcsValue
;
1394 // Sanity check for calculation of sucessful count
1395 if (pAdapter
->WlanCounters
.TransmittedFragmentCount
.QuadPart
< pAdapter
->WlanCounters
.RetryCount
.QuadPart
)
1396 pAdapter
->WlanCounters
.TransmittedFragmentCount
.QuadPart
= pAdapter
->WlanCounters
.RetryCount
.QuadPart
;
1398 Statistics
.TransmittedFragmentCount
.QuadPart
= pAdapter
->WlanCounters
.TransmittedFragmentCount
.QuadPart
;
1399 Statistics
.MulticastTransmittedFrameCount
.QuadPart
= pAdapter
->WlanCounters
.MulticastTransmittedFrameCount
.QuadPart
;
1400 Statistics
.FailedCount
.QuadPart
= pAdapter
->WlanCounters
.FailedCount
.QuadPart
;
1401 Statistics
.RetryCount
.QuadPart
= pAdapter
->WlanCounters
.RetryCount
.QuadPart
;
1402 Statistics
.MultipleRetryCount
.QuadPart
= pAdapter
->WlanCounters
.MultipleRetryCount
.QuadPart
;
1403 Statistics
.RTSSuccessCount
.QuadPart
= pAdapter
->WlanCounters
.RTSSuccessCount
.QuadPart
;
1404 Statistics
.RTSFailureCount
.QuadPart
= pAdapter
->WlanCounters
.RTSFailureCount
.QuadPart
;
1405 Statistics
.ACKFailureCount
.QuadPart
= pAdapter
->WlanCounters
.ACKFailureCount
.QuadPart
;
1406 Statistics
.FrameDuplicateCount
.QuadPart
= pAdapter
->WlanCounters
.FrameDuplicateCount
.QuadPart
;
1407 Statistics
.ReceivedFragmentCount
.QuadPart
= pAdapter
->WlanCounters
.ReceivedFragmentCount
.QuadPart
;
1408 Statistics
.MulticastReceivedFrameCount
.QuadPart
= pAdapter
->WlanCounters
.MulticastReceivedFrameCount
.QuadPart
;
1410 Statistics
.FCSErrorCount
= pAdapter
->RalinkCounters
.RealFcsErrCount
;
1412 Statistics
.FCSErrorCount
.QuadPart
= pAdapter
->WlanCounters
.FCSErrorCount
.QuadPart
;
1413 Statistics
.FrameDuplicateCount
.vv
.LowPart
= pAdapter
->WlanCounters
.FrameDuplicateCount
.vv
.LowPart
/ 100;
1415 wrq
->u
.data
.length
= sizeof(NDIS_802_11_STATISTICS
);
1416 Status
= copy_to_user(wrq
->u
.data
.pointer
, &Statistics
, wrq
->u
.data
.length
);
1418 case OID_GEN_RCV_OK
:
1419 DBGPRINT(RT_DEBUG_INFO
, "Query::OID_GEN_RCV_OK \n");
1420 ulInfo
= pAdapter
->Counters
.GoodReceives
;
1421 wrq
->u
.data
.length
= sizeof(ulInfo
);
1422 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
1424 case OID_GEN_RCV_NO_BUFFER
:
1425 DBGPRINT(RT_DEBUG_INFO
, "Query::OID_GEN_RCV_NO_BUFFER \n");
1426 ulInfo
= pAdapter
->Counters
.RxNoBuffer
;
1427 wrq
->u
.data
.length
= sizeof(ulInfo
);
1428 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
1430 case RT_OID_802_11_PHY_MODE
:
1431 ulInfo
= (ULONG
)pAdapter
->PortCfg
.PhyMode
;
1432 wrq
->u
.data
.length
= sizeof(ulInfo
);
1433 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
1434 DBGPRINT(RT_DEBUG_TRACE
, "Query::RT_OID_802_11_PHY_MODE (=%d)\n", ulInfo
);
1436 case RT_OID_802_11_STA_CONFIG
:
1437 DBGPRINT(RT_DEBUG_TRACE
, "Query::RT_OID_802_11_QUERY_STA_CONFIG\n");
1438 StaConfig
.EnableTxBurst
= pAdapter
->PortCfg
.EnableTxBurst
;
1439 StaConfig
.EnableTurboRate
= pAdapter
->PortCfg
.EnableTurboRate
;
1440 StaConfig
.UseBGProtection
= pAdapter
->PortCfg
.UseBGProtection
;
1441 StaConfig
.UseShortSlotTime
= pAdapter
->PortCfg
.UseShortSlotTime
;
1442 StaConfig
.AdhocMode
= pAdapter
->PortCfg
.AdhocMode
;
1443 StaConfig
.HwRadioStatus
= (pAdapter
->PortCfg
.bHwRadio
== TRUE
) ? 1 : 0;
1445 StaConfig
.SystemErrorBitmap
= pAdapter
->PortCfg
.SystemErrorBitmap
;
1446 wrq
->u
.data
.length
= sizeof(RT_802_11_STA_CONFIG
);
1447 Status
= copy_to_user(wrq
->u
.data
.pointer
, &StaConfig
, wrq
->u
.data
.length
);
1449 case OID_802_11_RTS_THRESHOLD
:
1450 RtsThresh
= pAdapter
->PortCfg
.RtsThreshold
;
1451 wrq
->u
.data
.length
= sizeof(RtsThresh
);
1452 Status
= copy_to_user(wrq
->u
.data
.pointer
, &RtsThresh
, wrq
->u
.data
.length
);
1453 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_RTS_THRESHOLD(=%d)\n", RtsThresh
);
1455 case OID_802_11_FRAGMENTATION_THRESHOLD
:
1456 FragThresh
= pAdapter
->PortCfg
.FragmentThreshold
;
1457 if (pAdapter
->PortCfg
.bFragmentZeroDisable
== TRUE
)
1459 wrq
->u
.data
.length
= sizeof(FragThresh
);
1460 Status
= copy_to_user(wrq
->u
.data
.pointer
, &FragThresh
, wrq
->u
.data
.length
);
1461 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%d)\n", FragThresh
);
1463 case OID_802_11_POWER_MODE
:
1464 PowerMode
= pAdapter
->PortCfg
.WindowsPowerMode
;
1465 wrq
->u
.data
.length
= sizeof(PowerMode
);
1466 Status
= copy_to_user(wrq
->u
.data
.pointer
, &PowerMode
, wrq
->u
.data
.length
);
1467 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode
);
1469 case RT_OID_802_11_RADIO
:
1470 RadioState
= (BOOLEAN
) pAdapter
->PortCfg
.bSwRadio
;
1471 wrq
->u
.data
.length
= sizeof(RadioState
);
1472 Status
= copy_to_user(wrq
->u
.data
.pointer
, &RadioState
, wrq
->u
.data
.length
);
1473 DBGPRINT(RT_DEBUG_TRACE
, "Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState
);
1475 case OID_802_11_INFRASTRUCTURE_MODE
:
1476 if (ADHOC_ON(pAdapter
))
1477 BssType
= Ndis802_11IBSS
;
1478 else if (INFRA_ON(pAdapter
))
1479 BssType
= Ndis802_11Infrastructure
;
1481 BssType
= Ndis802_11AutoUnknown
;
1483 wrq
->u
.data
.length
= sizeof(BssType
);
1484 Status
= copy_to_user(wrq
->u
.data
.pointer
, &BssType
, wrq
->u
.data
.length
);
1485 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType
);
1487 case RT_OID_802_11_PREAMBLE
:
1488 PreamType
= pAdapter
->PortCfg
.WindowsTxPreamble
;
1489 wrq
->u
.data
.length
= sizeof(PreamType
);
1490 Status
= copy_to_user(wrq
->u
.data
.pointer
, &PreamType
, wrq
->u
.data
.length
);
1491 DBGPRINT(RT_DEBUG_TRACE
, "Query::RT_OID_802_11_QUERY_PREAMBLE(=%d)\n", PreamType
);
1493 case OID_802_11_AUTHENTICATION_MODE
:
1494 AuthMode
= pAdapter
->PortCfg
.AuthMode
;
1495 wrq
->u
.data
.length
= sizeof(AuthMode
);
1496 Status
= copy_to_user(wrq
->u
.data
.pointer
, &AuthMode
, wrq
->u
.data
.length
);
1497 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode
);
1499 case OID_802_11_WEP_STATUS
:
1500 WepStatus
= pAdapter
->PortCfg
.WepStatus
;
1501 wrq
->u
.data
.length
= sizeof(WepStatus
);
1502 Status
= copy_to_user(wrq
->u
.data
.pointer
, &WepStatus
, wrq
->u
.data
.length
);
1503 DBGPRINT(RT_DEBUG_TRACE
, "Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus
);
1506 case RT_OID_802_11_QUERY_EEPROM_VERSION
:
1507 wrq
->u
.data
.length
= sizeof(ULONG
);
1508 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAdapter
->PortCfg
.EepromVersion
, wrq
->u
.data
.length
);
1509 DBGPRINT(RT_DEBUG_TRACE
, "Query::RT_OID_802_11_QUERY_EEPROM_VERSION (=%d)\n", pAdapter
->PortCfg
.EepromVersion
);
1513 DBGPRINT(RT_DEBUG_TRACE
, "Query::unknown IOCTL's subcmd = 0x%08x\n", cmd
);
1514 Status
= -EOPNOTSUPP
;
1522 IN
struct net_device
*net_dev
,
1523 IN OUT
struct ifreq
*rq
,
1526 PRTMP_ADAPTER pAdapter
= net_dev
->priv
;
1527 struct iwreq
*wrq
= (struct iwreq
*) rq
;
1528 struct iw_point
*erq
= NULL
;
1529 struct iw_freq
*frq
= NULL
;
1530 NDIS_802_11_SSID Ssid
, *pSsid
=NULL
;
1531 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType
= Ndis802_11Infrastructure
;
1532 NDIS_802_11_RTS_THRESHOLD RtsThresh
;
1533 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh
;
1534 NDIS_802_11_MAC_ADDRESS Bssid
;
1535 INT Status
= NDIS_STATUS_SUCCESS
;
1537 BOOLEAN StateMachineTouched
= FALSE
;
1538 int i
, chan
= -1, index
= 0, len
= 0;
1540 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1542 DBGPRINT(RT_DEBUG_TRACE
, "INFO::Network is down!\n");
1548 DBGPRINT(RT_DEBUG_TRACE
, "IOCTL::SIOCGIWNAME\n");
1549 strcpy(wrq
->u
.name
, "RT2500 Wireless"); //Less then 16 bytes.
1551 case SIOCSIWESSID
: //Set ESSID
1552 erq
= &wrq
->u
.essid
;
1553 memset(&Ssid
, 0x00, sizeof(NDIS_802_11_SSID
));
1556 if (erq
->length
> IW_ESSID_MAX_SIZE
)
1562 Status
= copy_from_user(Ssid
.Ssid
, erq
->pointer
, (erq
->length
- 1));
1563 Ssid
.SsidLength
= erq
->length
- 1; //minus null character.
1566 Ssid
.SsidLength
= 0; // ANY ssid
1569 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
1571 MlmeRestartStateMachine(pAdapter
);
1572 DBGPRINT(RT_DEBUG_TRACE
, "!!! MLME busy, reset MLME state machine !!!\n");
1575 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1576 // this request, because this request is initiated by NDIS.
1577 pAdapter
->Mlme
.CntlAux
.CurrReqIsFromNdis
= FALSE
;
1579 MlmeEnqueue(&pAdapter
->Mlme
.Queue
,
1580 MLME_CNTL_STATE_MACHINE
,
1582 sizeof(NDIS_802_11_SSID
),
1585 Status
= NDIS_STATUS_SUCCESS
;
1586 StateMachineTouched
= TRUE
;
1588 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWESSID[cmd=0x%x] (Len=%d,Ssid=%s)\n", SIOCSIWESSID
, pSsid
->SsidLength
, pSsid
->Ssid
);
1590 case SIOCGIWESSID
: //Get ESSID
1591 erq
= &wrq
->u
.essid
;
1593 if(pAdapter
->MediaState
== NdisMediaStateConnected
)
1596 erq
->length
= pAdapter
->PortCfg
.SsidLen
;
1597 Status
= copy_to_user(erq
->pointer
, pAdapter
->PortCfg
.Ssid
, erq
->length
);
1600 {//the ANY ssid was specified
1604 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCGIWESSID (Len=%d, ssid=%lu...)\n", erq
->length
, (unsigned long)erq
->pointer
);
1606 case SIOCGIWNWID
: // get network id
1607 Status
= -EOPNOTSUPP
;
1609 case SIOCSIWNWID
: // set network id (the cell)
1610 Status
= -EOPNOTSUPP
;
1612 case SIOCSIWFREQ
: // set channel/frequency (Hz)
1614 if((frq
->e
== 0) && (frq
->m
<= 1000))
1615 chan
= frq
->m
; // Setting by channel number
1617 MAP_KHZ_TO_CHANNEL_ID( (frq
->m
/100) , chan
); // Setting by frequency - search the table , like 2.412G, 2.422G,
1618 pAdapter
->PortCfg
.IbssConfig
.Channel
= chan
;
1619 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ
, pAdapter
->PortCfg
.IbssConfig
.Channel
);
1621 case SIOCGIWFREQ
: // get channel/frequency (Hz)
1622 if (INFRA_ON(pAdapter
) || ADHOC_ON(pAdapter
))
1623 wrq
->u
.freq
.m
= pAdapter
->PortCfg
.Channel
;
1625 wrq
->u
.freq
.m
= pAdapter
->PortCfg
.IbssConfig
.Channel
;
1629 case SIOCGIWNICKN
: //get node name/nickname
1631 erq
->length
= strlen(pAdapter
->nickn
);
1632 Status
= copy_to_user(erq
->pointer
, pAdapter
->nickn
, erq
->length
);
1634 case SIOCSIWNICKN
: //set node name/nickname
1638 if (erq
->length
<= IW_ESSID_MAX_SIZE
)
1639 Status
= copy_from_user(pAdapter
->nickn
, erq
->pointer
, erq
->length
);
1644 case SIOCGIWRATE
: //get default bit rate (bps)
1645 wrq
->u
.bitrate
.value
= RateIdToMbps
[pAdapter
->PortCfg
.TxRate
] * 1000000;
1646 wrq
->u
.bitrate
.disabled
= 0;
1648 case SIOCSIWRATE
: //set default bit rate (bps)
1649 RTMPSetDesiredRates(pAdapter
, wrq
->u
.bitrate
.value
);
1651 case SIOCGIWRTS
: // get RTS/CTS threshold (bytes)
1652 wrq
->u
.rts
.value
= (INT
) pAdapter
->PortCfg
.RtsThreshold
;
1653 wrq
->u
.rts
.disabled
= (wrq
->u
.rts
.value
== MAX_RTS_THRESHOLD
);
1654 wrq
->u
.rts
.fixed
= 1;
1656 case SIOCSIWRTS
: //set RTS/CTS threshold (bytes)
1657 RtsThresh
= wrq
->u
.rts
.value
;
1658 if (wrq
->u
.rts
.disabled
)
1659 RtsThresh
= MAX_RTS_THRESHOLD
;
1661 if((RtsThresh
> 0) && (RtsThresh
<= MAX_RTS_THRESHOLD
))
1662 pAdapter
->PortCfg
.RtsThreshold
= (USHORT
)RtsThresh
;
1663 else if (RtsThresh
== 0)
1664 pAdapter
->PortCfg
.RtsThreshold
= MAX_RTS_THRESHOLD
;
1666 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWRTS (=%d)\n", pAdapter
->PortCfg
.RtsThreshold
);
1668 case SIOCGIWFRAG
: //get fragmentation thr (bytes)
1669 wrq
->u
.frag
.value
= (INT
) pAdapter
->PortCfg
.FragmentThreshold
;
1670 wrq
->u
.frag
.disabled
= (wrq
->u
.frag
.value
>= MAX_FRAG_THRESHOLD
);
1671 wrq
->u
.frag
.fixed
= 1;
1673 case SIOCSIWFRAG
: //set fragmentation thr (bytes)
1674 FragThresh
= wrq
->u
.frag
.value
;
1675 if (wrq
->u
.rts
.disabled
)
1676 FragThresh
= MAX_FRAG_THRESHOLD
;
1678 if ( (FragThresh
>= MIN_FRAG_THRESHOLD
) && (FragThresh
<= MAX_FRAG_THRESHOLD
))
1679 pAdapter
->PortCfg
.FragmentThreshold
= (USHORT
)FragThresh
;
1680 else if (FragThresh
== 0)
1681 pAdapter
->PortCfg
.FragmentThreshold
= MAX_FRAG_THRESHOLD
;
1683 if (pAdapter
->PortCfg
.FragmentThreshold
== MAX_FRAG_THRESHOLD
)
1684 pAdapter
->PortCfg
.bFragmentZeroDisable
= TRUE
;
1686 pAdapter
->PortCfg
.bFragmentZeroDisable
= FALSE
;
1688 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWFRAG (=%d)\n", pAdapter
->PortCfg
.FragmentThreshold
);
1690 case SIOCGIWENCODE
: //get encoding token & mode
1691 index
= (wrq
->u
.encoding
.flags
& IW_ENCODE_INDEX
) - 1;
1692 if ((index
< 0) || (index
>= NR_WEP_KEYS
))
1693 index
= pAdapter
->PortCfg
.DefaultKeyId
; // Default key for tx (shared key)
1695 if (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeOpen
)
1696 wrq
->u
.encoding
.flags
= IW_ENCODE_OPEN
;
1697 else if (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeShared
)
1698 wrq
->u
.encoding
.flags
= IW_ENCODE_RESTRICTED
;
1700 if (pAdapter
->PortCfg
.WepStatus
== Ndis802_11WEPDisabled
)
1701 wrq
->u
.encoding
.flags
|= IW_ENCODE_DISABLED
;
1704 if(wrq
->u
.encoding
.pointer
)
1706 wrq
->u
.encoding
.length
= pAdapter
->PortCfg
.SharedKey
[index
].KeyLen
;
1707 Status
= copy_to_user(wrq
->u
.encoding
.pointer
,
1708 pAdapter
->PortCfg
.SharedKey
[index
].Key
,
1709 pAdapter
->PortCfg
.SharedKey
[index
].KeyLen
);
1710 wrq
->u
.encoding
.flags
|= (index
+ 1);
1714 case SIOCSIWENCODE
: //set encoding token & mode
1715 index
= (wrq
->u
.encoding
.flags
& IW_ENCODE_INDEX
) - 1;
1716 /* take the old default key if index is invalid */
1717 if((index
< 0) || (index
>= NR_WEP_KEYS
))
1718 index
= pAdapter
->PortCfg
.DefaultKeyId
; // Default key for tx (shared key)
1720 if(wrq
->u
.encoding
.pointer
)
1722 len
= wrq
->u
.encoding
.length
;
1723 if(len
> WEP_LARGE_KEY_LEN
)
1724 len
= WEP_LARGE_KEY_LEN
;
1726 memset(pAdapter
->PortCfg
.SharedKey
[index
].Key
, 0x00, MAX_LEN_OF_KEY
);
1727 Status
= copy_from_user(pAdapter
->PortCfg
.SharedKey
[index
].Key
,
1728 wrq
->u
.encoding
.pointer
, len
);
1729 pAdapter
->PortCfg
.SharedKey
[index
].KeyLen
= len
<= WEP_SMALL_KEY_LEN
? WEP_SMALL_KEY_LEN
: WEP_LARGE_KEY_LEN
;
1731 pAdapter
->PortCfg
.DefaultKeyId
= (UCHAR
) index
;
1732 if (wrq
->u
.encoding
.flags
& IW_ENCODE_DISABLED
)
1733 pAdapter
->PortCfg
.WepStatus
= Ndis802_11WEPDisabled
;
1735 pAdapter
->PortCfg
.WepStatus
= Ndis802_11WEPEnabled
;
1737 if (wrq
->u
.encoding
.flags
& IW_ENCODE_RESTRICTED
)
1738 pAdapter
->PortCfg
.AuthMode
= Ndis802_11AuthModeShared
;
1740 pAdapter
->PortCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
1742 if(pAdapter
->PortCfg
.WepStatus
== Ndis802_11WEPDisabled
)
1743 pAdapter
->PortCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
1746 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWENCODE Key[%x] => \n", index
);
1747 for (i
= 0; i
< len
; i
++)
1749 DBGPRINT(RT_DEBUG_TRACE
, "%02x:", pAdapter
->PortCfg
.SharedKey
[index
].Key
[i
]);
1751 DBGPRINT(RT_DEBUG_TRACE
, "\n");
1753 DBGPRINT(RT_DEBUG_TRACE
, "\n");
1756 case SIOCGIWAP
: //get access point MAC addresses
1757 if (INFRA_ON(pAdapter
) || ADHOC_ON(pAdapter
))
1759 wrq
->u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1760 memcpy(wrq
->u
.ap_addr
.sa_data
, &pAdapter
->PortCfg
.Bssid
, ETH_ALEN
);
1762 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCGIWAP(=%02x:%02x:%02x:%02x:%02x:%02x)\n",
1763 pAdapter
->PortCfg
.Bssid
.Octet
[0], pAdapter
->PortCfg
.Bssid
.Octet
[1], pAdapter
->PortCfg
.Bssid
.Octet
[2],
1764 pAdapter
->PortCfg
.Bssid
.Octet
[3], pAdapter
->PortCfg
.Bssid
.Octet
[4], pAdapter
->PortCfg
.Bssid
.Octet
[5]);
1768 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCGIWAP(=EMPTY)\n");
1772 case SIOCSIWAP
: //set access point MAC addresses
1773 memcpy(&Bssid
, &wrq
->u
.ap_addr
.sa_data
, sizeof(NDIS_802_11_MAC_ADDRESS
));
1774 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
1776 MlmeRestartStateMachine(pAdapter
);
1777 DBGPRINT(RT_DEBUG_TRACE
, "!!! MLME busy, reset MLME state machine !!!\n");
1780 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1781 // this request, because this request is initiated by NDIS.
1782 pAdapter
->Mlme
.CntlAux
.CurrReqIsFromNdis
= FALSE
;
1784 MlmeEnqueue(&pAdapter
->Mlme
.Queue
,
1785 MLME_CNTL_STATE_MACHINE
,
1787 sizeof(NDIS_802_11_MAC_ADDRESS
),
1789 Status
= NDIS_STATUS_SUCCESS
;
1790 StateMachineTouched
= TRUE
;
1791 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
1792 Bssid
[0], Bssid
[1], Bssid
[2], Bssid
[3], Bssid
[4], Bssid
[5]);
1794 case SIOCGIWMODE
: //get operation mode
1795 if (ADHOC_ON(pAdapter
))
1797 BssType
= Ndis802_11IBSS
;
1798 wrq
->u
.mode
= IW_MODE_ADHOC
;
1800 else if (INFRA_ON(pAdapter
))
1802 BssType
= Ndis802_11Infrastructure
;
1803 wrq
->u
.mode
= IW_MODE_INFRA
;
1807 BssType
= Ndis802_11AutoUnknown
;
1808 wrq
->u
.mode
= IW_MODE_AUTO
;
1810 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCGIWMODE(=%d)\n", BssType
);
1812 case SIOCSIWMODE
: //set operation mode
1813 if(wrq
->u
.mode
== IW_MODE_ADHOC
)
1815 if (pAdapter
->PortCfg
.BssType
!= BSS_INDEP
)
1817 // Config has changed
1818 pAdapter
->bConfigChanged
= TRUE
;
1820 pAdapter
->PortCfg
.BssType
= BSS_INDEP
;
1821 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWMODE (AD-HOC)\n");
1823 else if (wrq
->u
.mode
== IW_MODE_INFRA
)
1825 if (pAdapter
->PortCfg
.BssType
!= BSS_INFRA
)
1827 // Config has changed
1828 pAdapter
->bConfigChanged
= TRUE
;
1830 pAdapter
->PortCfg
.BssType
= BSS_INFRA
;
1831 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWMODE (INFRA)\n");
1836 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::SIOCSIWMODE (unknown)\n");
1838 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
1839 pAdapter
->PortCfg
.WpaState
= SS_NOTUSE
;
1841 case SIOCGIWSENS
: //get sensitivity (dBm)
1842 case SIOCSIWSENS
: //set sensitivity (dBm)
1843 case SIOCGIWPOWER
: //get Power Management settings
1844 case SIOCSIWPOWER
: //set Power Management settings
1845 case SIOCGIWTXPOW
: //get transmit power (dBm)
1846 case SIOCSIWTXPOW
: //set transmit power (dBm)
1847 Status
= -EOPNOTSUPP
;
1850 subcmd
= wrq
->u
.data
.flags
;
1851 if( subcmd
& OID_GET_SET_TOGGLE
)
1852 Status
= RTMPSetInformation(pAdapter
, rq
, subcmd
);
1854 Status
= RTMPQueryInformation(pAdapter
, rq
, subcmd
);
1857 if (wrq
->u
.data
.pointer
) {
1859 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
1860 access_ok(VERIFY_WRITE
, wrq
->u
.data
.pointer
, sizeof(privtab
))
1862 verify_area(VERIFY_WRITE
, wrq
->u
.data
.pointer
, sizeof(privtab
))
1867 wrq
->u
.data
.length
= sizeof(privtab
) / sizeof(privtab
[0]);
1868 if (copy_to_user(wrq
->u
.data
.pointer
, privtab
, sizeof(privtab
)))
1872 case RTPRIV_IOCTL_SET
:
1878 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
1879 access_ok(VERIFY_WRITE
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
)
1881 verify_area(VERIFY_WRITE
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
)
1886 while ((this_char
= strsep((char**)&wrq
->u
.data
.pointer
, ",")) != NULL
)
1891 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
1894 if (!value
|| !*value
)
1897 for (PRTMP_PRIVATE_SET_PROC
= RTMP_PRIVATE_SUPPORT_PROC
; PRTMP_PRIVATE_SET_PROC
->name
; PRTMP_PRIVATE_SET_PROC
++)
1899 if (strcmp(this_char
, PRTMP_PRIVATE_SET_PROC
->name
) == 0)
1901 if(!PRTMP_PRIVATE_SET_PROC
->set_proc(pAdapter
, value
))
1902 { //FALSE:Set private failed then return Invalid argument
1905 break; //Exit for loop.
1909 if(PRTMP_PRIVATE_SET_PROC
->name
== NULL
)
1910 { //Not found argument
1912 DBGPRINT(RT_DEBUG_TRACE
, "ioctl::(iwpriv) Not Support Set Command [%s=%s]\n", this_char
, value
);
1919 case RTPRIV_IOCTL_BBP
:
1920 RTMPIoctlBBP(pAdapter
, wrq
);
1923 case RTPRIV_IOCTL_MAC
:
1924 RTMPIoctlMAC(pAdapter
, wrq
);
1928 case RTPRIV_IOCTL_E2P
:
1929 RTMPIoctlE2PROM(pAdapter
, wrq
);
1933 DBGPRINT(RT_DEBUG_TRACE
, "IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd
);
1934 Status
= -EOPNOTSUPP
;
1938 if(StateMachineTouched
) // Upper layer sent a MLME-related operations
1939 MlmeHandler(pAdapter
);
1945 UCHAR BCAST
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1947 ========================================================================
1949 Routine Description:
1953 pAdapter Pointer to our adapter
1954 pBuf Pointer to the where the key stored
1957 NDIS_SUCCESS Add key successfully
1961 ========================================================================
1963 NDIS_STATUS
RTMPWPAAddKeyProc(
1964 IN PRTMP_ADAPTER pAdapter
,
1967 PNDIS_802_11_KEY pKey
;
1970 PUCHAR pTxMic
, pRxMic
;
1971 BOOLEAN bTxKey
; // Set the key as transmit key
1972 BOOLEAN bPairwise
; // Indicate the key is pairwise key
1973 BOOLEAN bKeyRSC
; // indicate the receive SC set by KeyRSC value.
1974 // Otherwise, it will set by the NIC.
1975 BOOLEAN bAuthenticator
; // indicate key is set by authenticator.
1978 pKey
= (PNDIS_802_11_KEY
) pBuf
;
1979 KeyIdx
= pKey
->KeyIndex
& 0xff;
1980 // Bit 31 of Add-key, Tx Key
1981 bTxKey
= (pKey
->KeyIndex
& 0x80000000) ? TRUE
: FALSE
;
1982 // Bit 30 of Add-key PairwiseKey
1983 bPairwise
= (pKey
->KeyIndex
& 0x40000000) ? TRUE
: FALSE
;
1984 // Bit 29 of Add-key KeyRSC
1985 bKeyRSC
= (pKey
->KeyIndex
& 0x20000000) ? TRUE
: FALSE
;
1986 // Bit 28 of Add-key Authenticator
1987 bAuthenticator
= (pKey
->KeyIndex
& 0x10000000) ? TRUE
: FALSE
;
1989 // 1. Check Group / Pairwise Key
1990 if (bPairwise
) // Pairwise Key
1992 // 1. KeyIdx must be 0, otherwise, return NDIS_STATUS_INVALID_DATA
1994 return(NDIS_STATUS_FAILURE
);
1996 // 2. Check bTx, it must be true, otherwise, return NDIS_STATUS_INVALID_DATA
1997 if (bTxKey
== FALSE
)
1998 return(NDIS_STATUS_FAILURE
);
2000 // 3. If BSSID is not all 0xff, return NDIS_STATUS_INVALID_DATA
2001 if (NdisEqualMemory(pKey
->BSSID
, BCAST
, 6))
2002 return(NDIS_STATUS_FAILURE
);
2004 // 4. Selct RxMic / TxMic based on Supp / Authenticator
2005 if (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
2007 // for WPA-None Tx, Rx MIC is the same
2008 pTxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 16;
2011 else if (bAuthenticator
== TRUE
)
2013 pTxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 16;
2014 pRxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 24;
2018 pRxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 16;
2019 pTxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 24;
2022 // 5. Find the old entry to overwrite or find an empty entry.
2024 for (i
= 0; i
< PAIRWISE_KEY_NO
; i
++)
2026 if (pAdapter
->PortCfg
.PairwiseKey
[i
].KeyLen
== 0)
2031 else if (RTMPEqualMemory(pAdapter
->PortCfg
.PairwiseKey
[i
].BssId
, pKey
->BSSID
, 6))
2033 // Found the old entry
2038 // If there is no match and no empty pairwise key, we have to replace an old one
2039 // which will be index 0 in our case.
2042 if (bKeyRSC
== TRUE
)
2044 NdisMoveMemory(&pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].RxTsc
, &pKey
->KeyRSC
, 6);
2048 NdisZeroMemory(pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].RxTsc
, 6);
2051 // 7. Copy information into Pairwise Key structure.
2052 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
2053 pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].KeyLen
= 16;
2054 NdisMoveMemory(pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].Key
, &pKey
->KeyMaterial
, 16);
2055 NdisMoveMemory(pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].RxMic
, pRxMic
, 8);
2056 NdisMoveMemory(pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].TxMic
, pTxMic
, 8);
2057 NdisMoveMemory(pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].BssId
, pKey
->BSSID
, 6);
2058 // Init TxTsc to one based on WiFi WPA specs
2059 pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].TxTsc
[0] = 1;
2060 pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].TxTsc
[1] = 0;
2061 pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].TxTsc
[2] = 0;
2062 pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].TxTsc
[3] = 0;
2063 pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].TxTsc
[4] = 0;
2064 pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].TxTsc
[5] = 0;
2065 Status
= NDIS_STATUS_SUCCESS
;
2068 printk("PairwiseKey Key (Index-%d) = ", PairwiseIdx
);
2069 for (i
= 0; i
< 16; i
++)
2071 printk("%02x:", pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].Key
[i
]);
2074 printk("PairwiseKey Rx MIC Key = ");
2075 for (i
= 0; i
< 8; i
++)
2077 printk("%02x:", pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].RxMic
[i
]);
2080 printk("PairwiseKey Tx MIC Key = ");
2081 for (i
= 0; i
< 8; i
++)
2083 printk("%02x:", pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].TxMic
[i
]);
2087 for (i
= 0; i
< 6; i
++)
2089 printk("%02x:", pAdapter
->PortCfg
.PairwiseKey
[PairwiseIdx
].RxTsc
[i
]);
2092 printk("BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
2093 pKey
->BSSID
[0],pKey
->BSSID
[1],pKey
->BSSID
[2],pKey
->BSSID
[3],pKey
->BSSID
[4],pKey
->BSSID
[5]);
2098 DBGPRINT(RT_DEBUG_TRACE
, "Ready to set Group key\n");
2099 // 1. Check BSSID, if not current BSSID or Bcast, return NDIS_STATUS_INVALID_DATA
2100 if ((!NdisEqualMemory(&pKey
->BSSID
, &BCAST
, 6)) &&
2101 (!NdisEqualMemory(&pKey
->BSSID
, &pAdapter
->PortCfg
.Bssid
, 6)))
2102 return(NDIS_STATUS_FAILURE
);
2105 // 2. Check Key index for supported Group Key
2106 if (KeyIdx
>= GROUP_KEY_NO
)
2107 return(NDIS_STATUS_FAILURE
);
2109 // 3. Set as default Tx Key if bTxKey is TRUE
2111 pAdapter
->PortCfg
.DefaultKeyId
= (UCHAR
) KeyIdx
;
2113 // 4. Selct RxMic / TxMic based on Supp / Authenticator
2114 if (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
2116 // for WPA-None Tx, Rx MIC is the same
2117 pTxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 16;
2120 else if (bAuthenticator
== TRUE
)
2122 pTxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 16;
2123 pRxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 24;
2127 pRxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 16;
2128 pTxMic
= (PUCHAR
) (&pKey
->KeyMaterial
) + 24;
2132 if (bKeyRSC
== TRUE
)
2134 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[KeyIdx
].RxTsc
, &pKey
->KeyRSC
, 6);
2138 NdisZeroMemory(pAdapter
->PortCfg
.GroupKey
[KeyIdx
].RxTsc
, 6);
2141 // 6. Copy information into Group Key structure.
2142 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
2143 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].KeyLen
= 16;
2144 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[KeyIdx
].Key
, &pKey
->KeyMaterial
, 16);
2145 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[KeyIdx
].RxMic
, pRxMic
, 8);
2146 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[KeyIdx
].TxMic
, pTxMic
, 8);
2147 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[KeyIdx
].BssId
, pKey
->BSSID
, 6);
2148 // Init TxTsc to one based on WiFi WPA specs
2149 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].TxTsc
[0] = 1;
2150 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].TxTsc
[1] = 0;
2151 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].TxTsc
[2] = 0;
2152 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].TxTsc
[3] = 0;
2153 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].TxTsc
[4] = 0;
2154 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].TxTsc
[5] = 0;
2155 // 802.1x port control
2156 pAdapter
->PortCfg
.PortSecured
= WPA_802_1X_PORT_SECURED
;
2157 Status
= NDIS_STATUS_SUCCESS
;
2159 // For WEP compatibility, in case it use OID_ADD_KEY, not OID_ADD_WEP
2160 if (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
2162 pAdapter
->PortCfg
.SharedKey
[KeyIdx
].KeyLen
= (UCHAR
) pKey
->KeyLength
;
2163 NdisMoveMemory(pAdapter
->PortCfg
.SharedKey
[KeyIdx
].Key
, &pKey
->KeyMaterial
, pKey
->KeyLength
);
2167 printk("GroupKey Key (Index-%d) = ",KeyIdx
);
2168 for (i
= 0; i
< 16; i
++)
2170 printk("%02x:", pAdapter
->PortCfg
.GroupKey
[KeyIdx
].Key
[i
]);
2173 printk("GroupKey Rx MIC Key = ");
2174 for (i
= 0; i
< 8; i
++)
2176 printk("%02x:", pAdapter
->PortCfg
.GroupKey
[KeyIdx
].RxMic
[i
]);
2179 printk("GroupKey Tx MIC Key = ");
2180 for (i
= 0; i
< 8; i
++)
2182 printk("%02x:", pAdapter
->PortCfg
.GroupKey
[KeyIdx
].TxMic
[i
]);
2187 for (i
= 0; i
< 6; i
++)
2189 printk("%02x:", pAdapter
->PortCfg
.GroupKey
[KeyIdx
].RxTsc
[i
]);
2192 printk("BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n",
2193 pKey
->BSSID
[0],pKey
->BSSID
[1],pKey
->BSSID
[2],pKey
->BSSID
[3],pKey
->BSSID
[4],pKey
->BSSID
[5]);
2200 ========================================================================
2202 Routine Description:
2203 Remove WPA Key process
2206 pAdapter Pointer to our adapter
2207 pBuf Pointer to the where the key stored
2210 NDIS_SUCCESS Add key successfully
2214 ========================================================================
2216 NDIS_STATUS
RTMPWPARemoveKeyProc(
2217 IN PRTMP_ADAPTER pAdapter
,
2220 PNDIS_802_11_REMOVE_KEY pKey
;
2222 NDIS_STATUS Status
= NDIS_STATUS_FAILURE
;
2223 BOOLEAN bTxKey
; // Set the key as transmit key
2224 BOOLEAN bPairwise
; // Indicate the key is pairwise key
2225 BOOLEAN bKeyRSC
; // indicate the receive SC set by KeyRSC value.
2226 // Otherwise, it will set by the NIC.
2227 BOOLEAN bAuthenticator
; // indicate key is set by authenticator.
2230 pKey
= (PNDIS_802_11_REMOVE_KEY
) pBuf
;
2231 KeyIdx
= pKey
->KeyIndex
& 0xff;
2232 // Bit 31 of Add-key, Tx Key
2233 bTxKey
= (pKey
->KeyIndex
& 0x80000000) ? TRUE
: FALSE
;
2234 // Bit 30 of Add-key PairwiseKey
2235 bPairwise
= (pKey
->KeyIndex
& 0x40000000) ? TRUE
: FALSE
;
2236 // Bit 29 of Add-key KeyRSC
2237 bKeyRSC
= (pKey
->KeyIndex
& 0x20000000) ? TRUE
: FALSE
;
2238 // Bit 28 of Add-key Authenticator
2239 bAuthenticator
= (pKey
->KeyIndex
& 0x10000000) ? TRUE
: FALSE
;
2241 // 1. If bTx is TRUE, return failure information
2243 return(NDIS_STATUS_FAILURE
);
2245 // 2. Check Pairwise Key
2248 // a. If BSSID is broadcast, remove all pairwise keys.
2249 if (NdisEqualMemory(&pKey
->BSSID
, &BCAST
, 6))
2251 for (i
= 0; i
< PAIRWISE_KEY_NO
; i
++)
2253 pAdapter
->PortCfg
.PairwiseKey
[i
].KeyLen
= 0;
2255 Status
= NDIS_STATUS_SUCCESS
;
2258 // b. If not broadcast, remove the pairwise specified by BSSID
2261 for (i
= 0; i
< PAIRWISE_KEY_NO
; i
++)
2263 if (NdisEqualMemory(pAdapter
->PortCfg
.PairwiseKey
[i
].BssId
, pKey
->BSSID
, 6))
2265 pAdapter
->PortCfg
.PairwiseKey
[i
].KeyLen
= 0;
2266 Status
= NDIS_STATUS_SUCCESS
;
2272 // c. If no pairwise supported, delete Group Key 0.
2273 // The will be false since we do support pairwise keys.
2278 // a. If BSSID is broadcast, remove all group keys indexed
2279 if (NdisEqualMemory(&pKey
->BSSID
, &BCAST
, 6))
2281 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].KeyLen
= 0;
2282 Status
= NDIS_STATUS_SUCCESS
;
2285 // b. If BSSID matched, delte the group key indexed.
2286 else if (NdisEqualMemory(pAdapter
->PortCfg
.GroupKey
[KeyIdx
].BssId
, pKey
->BSSID
, 6))
2288 pAdapter
->PortCfg
.GroupKey
[KeyIdx
].KeyLen
= 0;
2289 Status
= NDIS_STATUS_SUCCESS
;
2292 // c. For WEP compatibility
2293 if (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
2295 pAdapter
->PortCfg
.SharedKey
[KeyIdx
].KeyLen
= 0;
2304 ========================================================================
2306 Routine Description:
2310 pAdapter Pointer to our adapter
2317 ========================================================================
2319 VOID
RTMPWPARemoveAllKeys(
2320 IN PRTMP_ADAPTER pAdapter
)
2324 // For WPA-None, there is no need to remove it, since WinXP won't set it again after
2325 // Link up. And it will be replaced if user changed it.
2326 if (pAdapter
->PortCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
2329 for (i
= 0; i
< PAIRWISE_KEY_NO
; i
++)
2331 pAdapter
->PortCfg
.PairwiseKey
[i
].KeyLen
= 0;
2334 for (i
= 0; i
< GROUP_KEY_NO
; i
++)
2336 pAdapter
->PortCfg
.GroupKey
[i
].KeyLen
= 0;
2341 ========================================================================
2343 Routine Description:
2344 Change NIC PHY mode. Re-association may be necessary.
2347 pAdapter Pointer to our adapter
2350 ========================================================================
2352 VOID
RTMPSetPhyMode(
2353 IN PRTMP_ADAPTER pAdapter
,
2358 DBGPRINT(RT_DEBUG_TRACE
,"RTMPSetPhyMode(=%d)\n", phymode
);
2360 // the selected phymode must be supported by the RF IC encoded in E2PROM
2361 if (pAdapter
->PortCfg
.RfType
< RFIC_5222
)
2363 if (phymode
== PHY_11A
)
2364 phymode
= PHY_11BG_MIXED
;
2367 // if no change, do nothing
2368 if (pAdapter
->PortCfg
.PhyMode
== phymode
)
2371 pAdapter
->PortCfg
.PhyMode
= (UCHAR
)phymode
;
2372 BuildChannelList(pAdapter
);
2374 for (i
= 0; i
< pAdapter
->PortCfg
.ChannelListNum
; i
++)
2376 if (pAdapter
->PortCfg
.IbssConfig
.Channel
== pAdapter
->PortCfg
.ChannelList
[i
])
2379 if (i
== pAdapter
->PortCfg
.ChannelListNum
)
2380 pAdapter
->PortCfg
.IbssConfig
.Channel
= FirstChannel(pAdapter
);
2381 pAdapter
->PortCfg
.Channel
= pAdapter
->PortCfg
.IbssConfig
.Channel
;
2383 AsicSwitchChannel(pAdapter
, pAdapter
->PortCfg
.Channel
);
2384 AsicLockChannel(pAdapter
, pAdapter
->PortCfg
.Channel
);
2388 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
2389 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
2390 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
2391 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
2392 pAdapter
->PortCfg
.IbssConfig
.SupportedRatesLen
= 4;
2393 pAdapter
->PortCfg
.SupportedRates
[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
2394 pAdapter
->PortCfg
.SupportedRates
[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
2395 pAdapter
->PortCfg
.SupportedRates
[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps
2396 pAdapter
->PortCfg
.SupportedRates
[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
2397 pAdapter
->PortCfg
.SupportedRatesLen
= 4;
2398 pAdapter
->PortCfg
.DesiredRates
[0] = 2; // 1 mbps, in units of 0.5 Mbps
2399 pAdapter
->PortCfg
.DesiredRates
[1] = 4; // 2 mbps, in units of 0.5 Mbps
2400 pAdapter
->PortCfg
.DesiredRates
[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
2401 pAdapter
->PortCfg
.DesiredRates
[3] = 22; // 11 mbps, in units of 0.5 Mbps
2402 pAdapter
->PortCfg
.DesiredRates
[4] = 0;
2403 pAdapter
->PortCfg
.DesiredRates
[5] = 0;
2404 pAdapter
->PortCfg
.DesiredRates
[6] = 0;
2405 pAdapter
->PortCfg
.DesiredRates
[7] = 0;
2406 pAdapter
->PortCfg
.DesiredRates
[8] = 0;
2407 pAdapter
->PortCfg
.DesiredRates
[9] = 0;
2408 pAdapter
->PortCfg
.DesiredRates
[10] = 0;
2409 pAdapter
->PortCfg
.DesiredRates
[11] = 0;
2412 case PHY_11BG_MIXED
:
2413 case PHY_11ABG_MIXED
:
2414 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
2415 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
2416 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
2417 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
2418 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[4] = 0x12; // 9 mbps, in units of 0.5 Mbps
2419 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[5] = 0x24; // 18 mbps, in units of 0.5 Mbps
2420 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[6] = 0x48; // 36 mbps, in units of 0.5 Mbps
2421 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
2422 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[8] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
2423 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[9] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
2424 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[10] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
2425 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[11] = 0x60; // 48 mbps, in units of 0.5 Mbps
2426 pAdapter
->PortCfg
.IbssConfig
.SupportedRatesLen
= 12;
2427 pAdapter
->PortCfg
.SupportedRates
[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate
2428 pAdapter
->PortCfg
.SupportedRates
[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate
2429 pAdapter
->PortCfg
.SupportedRates
[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate
2430 pAdapter
->PortCfg
.SupportedRates
[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate
2431 pAdapter
->PortCfg
.SupportedRates
[4] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
2432 pAdapter
->PortCfg
.SupportedRates
[5] = 0x12; // 9 mbps, in units of 0.5 Mbps
2433 pAdapter
->PortCfg
.SupportedRates
[6] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
2434 pAdapter
->PortCfg
.SupportedRates
[7] = 0x24; // 18 mbps, in units of 0.5 Mbps
2435 pAdapter
->PortCfg
.SupportedRates
[8] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
2436 pAdapter
->PortCfg
.SupportedRates
[9] = 0x48; // 36 mbps, in units of 0.5 Mbps
2437 pAdapter
->PortCfg
.SupportedRates
[10] = 0x60; // 48 mbps, in units of 0.5 Mbps
2438 pAdapter
->PortCfg
.SupportedRates
[11] = 0x6c; // 54 mbps, in units of 0.5 Mbps
2439 pAdapter
->PortCfg
.SupportedRatesLen
= 12;
2440 pAdapter
->PortCfg
.DesiredRates
[0] = 2; // 1 mbps, in units of 0.5 Mbps
2441 pAdapter
->PortCfg
.DesiredRates
[1] = 4; // 2 mbps, in units of 0.5 Mbps
2442 pAdapter
->PortCfg
.DesiredRates
[2] = 11; // 5.5 mbps, in units of 0.5 Mbps
2443 pAdapter
->PortCfg
.DesiredRates
[3] = 22; // 11 mbps, in units of 0.5 Mbps
2444 pAdapter
->PortCfg
.DesiredRates
[4] = 12; // 6 mbps, in units of 0.5 Mbps
2445 pAdapter
->PortCfg
.DesiredRates
[5] = 18; // 9 mbps, in units of 0.5 Mbps
2446 pAdapter
->PortCfg
.DesiredRates
[6] = 24; // 12 mbps, in units of 0.5 Mbps
2447 pAdapter
->PortCfg
.DesiredRates
[7] = 36; // 18 mbps, in units of 0.5 Mbps
2448 pAdapter
->PortCfg
.DesiredRates
[8] = 48; // 24 mbps, in units of 0.5 Mbps
2449 pAdapter
->PortCfg
.DesiredRates
[9] = 72; // 36 mbps, in units of 0.5 Mbps
2450 pAdapter
->PortCfg
.DesiredRates
[10] = 96; // 48 mbps, in units of 0.5 Mbps
2451 pAdapter
->PortCfg
.DesiredRates
[11] = 108; // 54 mbps, in units of 0.5 Mbps
2455 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
2456 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
2457 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
2458 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
2459 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
2460 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
2461 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
2462 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
2463 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[8] = 0;
2464 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[9] = 0;
2465 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[10] = 0;
2466 pAdapter
->PortCfg
.IbssConfig
.SupportedRates
[11] = 0;
2467 pAdapter
->PortCfg
.IbssConfig
.SupportedRatesLen
= 8;
2468 pAdapter
->PortCfg
.SupportedRates
[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate
2469 pAdapter
->PortCfg
.SupportedRates
[1] = 0x12; // 9 mbps, in units of 0.5 Mbps
2470 pAdapter
->PortCfg
.SupportedRates
[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate
2471 pAdapter
->PortCfg
.SupportedRates
[3] = 0x24; // 18 mbps, in units of 0.5 Mbps
2472 pAdapter
->PortCfg
.SupportedRates
[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate
2473 pAdapter
->PortCfg
.SupportedRates
[5] = 0x48; // 36 mbps, in units of 0.5 Mbps
2474 pAdapter
->PortCfg
.SupportedRates
[6] = 0x60; // 48 mbps, in units of 0.5 Mbps
2475 pAdapter
->PortCfg
.SupportedRates
[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps
2476 pAdapter
->PortCfg
.SupportedRates
[8] = 0;
2477 pAdapter
->PortCfg
.SupportedRates
[9] = 0;
2478 pAdapter
->PortCfg
.SupportedRates
[10] = 0;
2479 pAdapter
->PortCfg
.SupportedRates
[11] = 0;
2480 pAdapter
->PortCfg
.SupportedRatesLen
= 8;
2481 pAdapter
->PortCfg
.DesiredRates
[0] = 12; // 6 mbps, in units of 0.5 Mbps
2482 pAdapter
->PortCfg
.DesiredRates
[1] = 18; // 9 mbps, in units of 0.5 Mbps
2483 pAdapter
->PortCfg
.DesiredRates
[2] = 24; // 12 mbps, in units of 0.5 Mbps
2484 pAdapter
->PortCfg
.DesiredRates
[3] = 36; // 18 mbps, in units of 0.5 Mbps
2485 pAdapter
->PortCfg
.DesiredRates
[4] = 48; // 24 mbps, in units of 0.5 Mbps
2486 pAdapter
->PortCfg
.DesiredRates
[5] = 72; // 36 mbps, in units of 0.5 Mbps
2487 pAdapter
->PortCfg
.DesiredRates
[6] = 96; // 48 mbps, in units of 0.5 Mbps
2488 pAdapter
->PortCfg
.DesiredRates
[7] = 108; // 54 mbps, in units of 0.5 Mbps
2489 pAdapter
->PortCfg
.DesiredRates
[8] = 0;
2490 pAdapter
->PortCfg
.DesiredRates
[9] = 0;
2491 pAdapter
->PortCfg
.DesiredRates
[10] = 0;
2492 pAdapter
->PortCfg
.DesiredRates
[11] = 0;
2499 MlmeUpdateTxRates(pAdapter
, FALSE
);
2500 AsicSetSlotTime(pAdapter
, FALSE
);
2501 MakeIbssBeacon(pAdapter
); // supported rates may change
2504 VOID
RTMPSetDesiredRates(
2505 IN PRTMP_ADAPTER pAdapter
,
2508 NDIS_802_11_RATES aryRates
;
2510 memset(&aryRates
, 0x00, sizeof(NDIS_802_11_RATES
));
2511 switch (pAdapter
->PortCfg
.PhyMode
)
2513 case PHY_11A
: // A only
2517 aryRates
[0] = 0x0c; // 6M
2520 aryRates
[0] = 0x12; // 9M
2522 case 12000000: //12M
2523 aryRates
[0] = 0x18; // 12M
2525 case 18000000: //18M
2526 aryRates
[0] = 0x24; // 18M
2528 case 24000000: //24M
2529 aryRates
[0] = 0x30; // 24M
2531 case 36000000: //36M
2532 aryRates
[0] = 0x48; // 36M
2534 case 48000000: //48M
2535 aryRates
[0] = 0x60; // 48M
2537 case 54000000: //54M
2538 aryRates
[0] = 0x6c; // 54M
2542 aryRates
[0] = 0x6c; // 54Mbps
2543 aryRates
[1] = 0x60; // 48Mbps
2544 aryRates
[2] = 0x48; // 36Mbps
2545 aryRates
[3] = 0x30; // 24Mbps
2546 aryRates
[4] = 0x24; // 18M
2547 aryRates
[5] = 0x18; // 12M
2548 aryRates
[6] = 0x12; // 9M
2549 aryRates
[7] = 0x0c; // 6M
2553 case PHY_11BG_MIXED
: // B/G Mixed
2554 case PHY_11B
: // B only
2555 case PHY_11ABG_MIXED
: // A/B/G Mixed
2565 case 5000000: //5.5M
2566 aryRates
[0] = 0x0b; // 5.5M
2568 case 11000000: //11M
2569 aryRates
[0] = 0x16; // 11M
2572 aryRates
[0] = 0x0c; // 6M
2575 aryRates
[0] = 0x12; // 9M
2577 case 12000000: //12M
2578 aryRates
[0] = 0x18; // 12M
2580 case 18000000: //18M
2581 aryRates
[0] = 0x24; // 18M
2583 case 24000000: //24M
2584 aryRates
[0] = 0x30; // 24M
2586 case 36000000: //36M
2587 aryRates
[0] = 0x48; // 36M
2589 case 48000000: //48M
2590 aryRates
[0] = 0x60; // 48M
2592 case 54000000: //54M
2593 aryRates
[0] = 0x6c; // 54M
2597 if (pAdapter
->PortCfg
.PhyMode
== PHY_11B
)
2599 aryRates
[0] = 0x16; // 11Mbps
2600 aryRates
[1] = 0x0b; // 5.5Mbps
2601 aryRates
[2] = 0x04; // 2Mbps
2602 aryRates
[3] = 0x02; // 1Mbps
2605 { //(B/G) Mixed or (A/B/G) Mixed
2606 aryRates
[0] = 0x6c; // 54Mbps
2607 aryRates
[1] = 0x60; // 48Mbps
2608 aryRates
[2] = 0x48; // 36Mbps
2609 aryRates
[3] = 0x30; // 24Mbps
2610 aryRates
[4] = 0x16; // 11Mbps
2611 aryRates
[5] = 0x0b; // 5.5Mbps
2612 aryRates
[6] = 0x04; // 2Mbps
2613 aryRates
[7] = 0x02; // 1Mbps
2620 NdisZeroMemory(pAdapter
->PortCfg
.DesiredRates
, MAX_LEN_OF_SUPPORTED_RATES
);
2621 NdisMoveMemory(pAdapter
->PortCfg
.DesiredRates
, &aryRates
, sizeof(NDIS_802_11_RATES
));
2622 DBGPRINT(RT_DEBUG_TRACE
, " RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
2623 pAdapter
->PortCfg
.DesiredRates
[0],pAdapter
->PortCfg
.DesiredRates
[1],
2624 pAdapter
->PortCfg
.DesiredRates
[2],pAdapter
->PortCfg
.DesiredRates
[3],
2625 pAdapter
->PortCfg
.DesiredRates
[4],pAdapter
->PortCfg
.DesiredRates
[5],
2626 pAdapter
->PortCfg
.DesiredRates
[6],pAdapter
->PortCfg
.DesiredRates
[7] );
2627 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
2628 MlmeUpdateTxRates(pAdapter
, FALSE
);
2631 ==========================================================================
2635 TRUE if all parameters are OK, FALSE otherwise
2636 ==========================================================================
2638 INT
Set_CountryRegion_Proc(
2639 IN PRTMP_ADAPTER pAdapter
,
2645 region
= simple_strtol(arg
, 0, 10);
2646 if( (region
>= REGION_MIN
) && (region
<= REGION_MAX
) )
2648 pAdapter
->PortCfg
.CountryRegion
= (UCHAR
) region
;
2649 DBGPRINT(RT_DEBUG_TRACE
, "Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAdapter
->PortCfg
.CountryRegion
);
2650 DBGPRINT(RT_DEBUG_TRACE
, "Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAdapter
->PortCfg
.CountryRegion
);
2658 ==========================================================================
2662 TRUE if all parameters are OK, FALSE otherwise
2663 ==========================================================================
2666 IN PRTMP_ADAPTER pAdapter
,
2669 NDIS_802_11_SSID Ssid
, *pSsid
=NULL
;
2670 BOOLEAN StateMachineTouched
= FALSE
;
2673 if( strlen(arg
) <= MAX_LEN_OF_SSID
)
2675 NdisZeroMemory(&Ssid
, MAX_LEN_OF_SSID
);
2676 NdisMoveMemory(Ssid
.Ssid
, arg
, strlen(arg
));
2677 Ssid
.SsidLength
= strlen(arg
);
2680 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
2682 MlmeRestartStateMachine(pAdapter
);
2683 DBGPRINT(RT_DEBUG_TRACE
, "!!! MLME busy, reset MLME state machine !!!\n");
2685 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
2686 // this request, because this request is initiated by NDIS.
2687 pAdapter
->Mlme
.CntlAux
.CurrReqIsFromNdis
= FALSE
;
2689 MlmeEnqueue(&pAdapter
->Mlme
.Queue
,
2690 MLME_CNTL_STATE_MACHINE
,
2692 sizeof(NDIS_802_11_SSID
),
2695 StateMachineTouched
= TRUE
;
2696 DBGPRINT(RT_DEBUG_TRACE
, "Set_SSID_Proc::(Len=%d,Ssid=%s)\n", pAdapter
->PortCfg
.SsidLen
, pAdapter
->PortCfg
.Ssid
);
2701 if (StateMachineTouched
) // Upper layer sent a MLME-related operations
2702 MlmeHandler(pAdapter
);
2707 ==========================================================================
2711 TRUE if all parameters are OK, FALSE otherwise
2712 ==========================================================================
2714 INT
Set_WirelessMode_Proc(
2715 IN PRTMP_ADAPTER pAdapter
,
2721 WirelessMode
= simple_strtol(arg
, 0, 10);
2723 if ((WirelessMode
== PHY_11BG_MIXED
) || (WirelessMode
== PHY_11B
) ||
2724 (WirelessMode
== PHY_11A
) || (WirelessMode
== PHY_11ABG_MIXED
))
2726 RTMPSetPhyMode(pAdapter
, WirelessMode
);
2727 DBGPRINT(RT_DEBUG_TRACE
, "Set_WirelessMode_Proc::(=%d)\n", WirelessMode
);
2735 ==========================================================================
2739 TRUE if all parameters are OK, FALSE otherwise
2740 ==========================================================================
2742 INT
Set_TxRate_Proc(
2743 IN PRTMP_ADAPTER pAdapter
,
2748 ULONG rate_mapping
[12] = {1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54}; //according to README
2750 TxRate
= simple_strtol(arg
, 0, 10);
2753 RTMPSetDesiredRates(pAdapter
, -1);
2755 RTMPSetDesiredRates(pAdapter
, (LONG
) (rate_mapping
[TxRate
-1] * 1000000));
2759 ==========================================================================
2761 Set AdhocMode support Rate can or can not exceed 11Mbps against WiFi spec.
2763 TRUE if all parameters are OK, FALSE otherwise
2764 ==========================================================================
2766 INT
Set_AdhocModeRate_Proc(
2767 IN PRTMP_ADAPTER pAdapter
,
2772 AdhocMode
= simple_strtol(arg
, 0, 10);
2775 pAdapter
->PortCfg
.AdhocMode
= 1;
2776 else if (AdhocMode
== 0)
2777 pAdapter
->PortCfg
.AdhocMode
= 0;
2779 return FALSE
; //Invalid argument
2781 DBGPRINT(RT_DEBUG_TRACE
, "Set_AdhocModeRate_Proc::(AdhocMode=%d)\n", pAdapter
->PortCfg
.AdhocMode
);
2786 ==========================================================================
2790 TRUE if all parameters are OK, FALSE otherwise
2791 ==========================================================================
2793 INT
Set_Channel_Proc(
2794 IN PRTMP_ADAPTER pAdapter
,
2800 Channel
= (UCHAR
) simple_strtol(arg
, 0, 10);
2802 if (ChannelSanity(pAdapter
, Channel
) == TRUE
)
2804 pAdapter
->PortCfg
.Channel
= Channel
;
2805 pAdapter
->PortCfg
.IbssConfig
.Channel
= Channel
;
2806 DBGPRINT(RT_DEBUG_TRACE
, "Set_Channel_Proc::(Channel=%d)\n", Channel
);
2814 ==========================================================================
2816 For Debug information
2818 TRUE if all parameters are OK, FALSE otherwise
2819 ==========================================================================
2823 IN PRTMP_ADAPTER pAdapter
,
2827 DBGPRINT(RT_DEBUG_TRACE
, "**************************************************************\n");
2828 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_Debug_Proc\n");
2831 if(simple_strtol(arg
, 0, 10) <= RT_DEBUG_LOUD
)
2832 RTDebugLevel
= simple_strtol(arg
, 0, 10);
2834 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_Debug_Proc\n");
2835 DBGPRINT(RT_DEBUG_TRACE
, "**************************************************************\n");
2840 ==========================================================================
2842 Set 11B/11G Protection
2844 TRUE if all parameters are OK, FALSE otherwise
2845 ==========================================================================
2847 INT
Set_BGProtection_Proc(
2848 IN PRTMP_ADAPTER pAdapter
,
2852 switch (simple_strtol(arg
, 0, 10))
2855 pAdapter
->PortCfg
.UseBGProtection
= 0;
2858 pAdapter
->PortCfg
.UseBGProtection
= 1;
2860 case 2: //Always OFF
2861 pAdapter
->PortCfg
.UseBGProtection
= 2;
2863 default: //Invalid argument
2866 DBGPRINT(RT_DEBUG_TRACE
, "Set_BGProtection_Proc::(BGProtection=%d)\n", pAdapter
->PortCfg
.UseBGProtection
);
2871 ==========================================================================
2873 Set StaWithEtherBridge function on/off
2875 TRUE if all parameters are OK, FALSE otherwise
2876 ==========================================================================
2878 INT
Set_StaWithEtherBridge_Proc(
2879 IN PRTMP_ADAPTER pAdapter
,
2883 switch (simple_strtol(arg
, 0, 10))
2886 pAdapter
->PortCfg
.StaWithEtherBridge
.Enable
= FALSE
;
2889 pAdapter
->PortCfg
.StaWithEtherBridge
.Enable
= TRUE
;
2891 default: //Invalid argument
2894 DBGPRINT(RT_DEBUG_TRACE
, "Set_StaWithEtherBridge_Proc::(StaWithEtherBridge=%d)\n", pAdapter
->PortCfg
.StaWithEtherBridge
.Enable
);
2899 ==========================================================================
2903 TRUE if all parameters are OK, FALSE otherwise
2904 ==========================================================================
2906 INT
Set_TxPreamble_Proc(
2907 IN PRTMP_ADAPTER pAdapter
,
2910 RT_802_11_PREAMBLE Preamble
;
2912 Preamble
= simple_strtol(arg
, 0, 10);
2915 case Rt802_11PreambleShort
:
2916 pAdapter
->PortCfg
.WindowsTxPreamble
= Preamble
;
2917 MlmeSetTxPreamble(pAdapter
, Rt802_11PreambleShort
);
2919 case Rt802_11PreambleLong
:
2920 case Rt802_11PreambleAuto
:
2921 // if user wants AUTO, initialize to LONG here, then change according to AP's
2922 // capability upon association.
2923 pAdapter
->PortCfg
.WindowsTxPreamble
= Preamble
;
2924 MlmeSetTxPreamble(pAdapter
, Rt802_11PreambleLong
);
2926 default: //Invalid argument
2930 DBGPRINT(RT_DEBUG_TRACE
, "Set_TxPreamble_Proc::(TxPreamble=%d)\n", Preamble
);
2935 ==========================================================================
2939 TRUE if all parameters are OK, FALSE otherwise
2940 ==========================================================================
2942 INT
Set_RTSThreshold_Proc(
2943 IN PRTMP_ADAPTER pAdapter
,
2946 NDIS_802_11_RTS_THRESHOLD RtsThresh
;
2948 RtsThresh
= simple_strtol(arg
, 0, 10);
2950 if((RtsThresh
> 0) && (RtsThresh
<= MAX_RTS_THRESHOLD
))
2951 pAdapter
->PortCfg
.RtsThreshold
= (USHORT
)RtsThresh
;
2952 else if (RtsThresh
== 0)
2953 pAdapter
->PortCfg
.RtsThreshold
= MAX_RTS_THRESHOLD
;
2957 DBGPRINT(RT_DEBUG_TRACE
, "Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAdapter
->PortCfg
.RtsThreshold
);
2961 ==========================================================================
2963 Set Fragment Threshold
2965 TRUE if all parameters are OK, FALSE otherwise
2966 ==========================================================================
2968 INT
Set_FragThreshold_Proc(
2969 IN PRTMP_ADAPTER pAdapter
,
2972 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh
;
2974 FragThresh
= simple_strtol(arg
, 0, 10);
2976 if ( (FragThresh
>= MIN_FRAG_THRESHOLD
) && (FragThresh
<= MAX_FRAG_THRESHOLD
))
2977 pAdapter
->PortCfg
.FragmentThreshold
= (USHORT
)FragThresh
;
2978 else if (FragThresh
== 0)
2979 pAdapter
->PortCfg
.FragmentThreshold
= MAX_FRAG_THRESHOLD
;
2981 return FALSE
; //Invalid argument
2983 if (pAdapter
->PortCfg
.FragmentThreshold
== MAX_FRAG_THRESHOLD
)
2984 pAdapter
->PortCfg
.bFragmentZeroDisable
= TRUE
;
2986 pAdapter
->PortCfg
.bFragmentZeroDisable
= FALSE
;
2988 DBGPRINT(RT_DEBUG_TRACE
, "Set_FragThreshold_Proc::(FragThreshold=%d)\n", FragThresh
);
2993 ==========================================================================
2997 TRUE if all parameters are OK, FALSE otherwise
2998 ==========================================================================
3000 INT
Set_TxBurst_Proc(
3001 IN PRTMP_ADAPTER pAdapter
,
3006 TxBurst
= simple_strtol(arg
, 0, 10);
3009 pAdapter
->PortCfg
.EnableTxBurst
= TRUE
;
3010 else if (TxBurst
== 0)
3011 pAdapter
->PortCfg
.EnableTxBurst
= FALSE
;
3013 return FALSE
; //Invalid argument
3015 DBGPRINT(RT_DEBUG_TRACE
, "Set_TxBurst_Proc::(TxBurst=%d)\n", pAdapter
->PortCfg
.EnableTxBurst
);
3020 ==========================================================================
3022 Set TurboRate Enable or Disable
3024 TRUE if all parameters are OK, FALSE otherwise
3025 ==========================================================================
3027 INT
Set_TurboRate_Proc(
3028 IN PRTMP_ADAPTER pAdapter
,
3033 TurboRate
= simple_strtol(arg
, 0, 10);
3036 pAdapter
->PortCfg
.EnableTurboRate
= TRUE
;
3037 else if (TurboRate
== 0)
3038 pAdapter
->PortCfg
.EnableTurboRate
= FALSE
;
3040 return FALSE
; //Invalid argument
3042 DBGPRINT(RT_DEBUG_TRACE
, "Set_TurboRate_Proc::(TurboRate=%d)\n", pAdapter
->PortCfg
.EnableTurboRate
);
3047 ==========================================================================
3049 Set Short Slot Time Enable or Disable
3051 TRUE if all parameters are OK, FALSE otherwise
3052 ==========================================================================
3054 INT
Set_ShortSlot_Proc(
3055 IN PRTMP_ADAPTER pAdapter
,
3060 ShortSlot
= simple_strtol(arg
, 0, 10);
3063 pAdapter
->PortCfg
.UseShortSlotTime
= TRUE
;
3064 else if (ShortSlot
== 0)
3065 pAdapter
->PortCfg
.UseShortSlotTime
= FALSE
;
3067 return FALSE
; //Invalid argument
3069 DBGPRINT(RT_DEBUG_TRACE
, "Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAdapter
->PortCfg
.UseShortSlotTime
);
3075 ==========================================================================
3077 Set Network Type(Infrastructure/Adhoc mode)
3079 TRUE if all parameters are OK, FALSE otherwise
3080 ==========================================================================
3082 INT
Set_NetworkType_Proc(
3083 IN PRTMP_ADAPTER pAdapter
,
3086 if (strcmp(arg
, "Adhoc") == 0)
3087 pAdapter
->PortCfg
.BssType
= BSS_INDEP
;
3088 else //Default Infrastructure mode
3089 pAdapter
->PortCfg
.BssType
= BSS_INFRA
;
3091 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
3092 pAdapter
->PortCfg
.WpaState
= SS_NOTUSE
;
3094 DBGPRINT(RT_DEBUG_TRACE
, "Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter
->PortCfg
.BssType
);
3100 ==========================================================================
3102 Set Authentication mode
3104 TRUE if all parameters are OK, FALSE otherwise
3105 ==========================================================================
3107 INT
Set_AuthMode_Proc(
3108 IN PRTMP_ADAPTER pAdapter
,
3111 if ((strcmp(arg
, "OPEN") == 0) || (strcmp(arg
, "open") == 0))
3112 pAdapter
->PortCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
3113 else if ((strcmp(arg
, "SHARED") == 0) || (strcmp(arg
, "shared") == 0))
3114 pAdapter
->PortCfg
.AuthMode
= Ndis802_11AuthModeShared
;
3115 else if ((strcmp(arg
, "AUTO") == 0) || (strcmp(arg
, "auto") == 0))
3116 pAdapter
->PortCfg
.AuthMode
= Ndis802_11AuthModeAutoSwitch
;
3117 else if ((strcmp(arg
, "WPAPSK") == 0) || (strcmp(arg
, "wpapsk") == 0))
3118 pAdapter
->PortCfg
.AuthMode
= Ndis802_11AuthModeWPAPSK
;
3119 else if ((strcmp(arg
, "WPANONE") == 0) || (strcmp(arg
, "wpanone") == 0))
3120 pAdapter
->PortCfg
.AuthMode
= Ndis802_11AuthModeWPANone
;
3124 pAdapter
->PortCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
3126 DBGPRINT(RT_DEBUG_TRACE
, "Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter
->PortCfg
.AuthMode
);
3132 ==========================================================================
3136 TRUE if all parameters are OK, FALSE otherwise
3137 ==========================================================================
3139 INT
Set_EncrypType_Proc(
3140 IN PRTMP_ADAPTER pAdapter
,
3143 if ((strcmp(arg
, "NONE") == 0) || (strcmp(arg
, "none") == 0))
3144 pAdapter
->PortCfg
.WepStatus
= Ndis802_11WEPDisabled
;
3145 else if ((strcmp(arg
, "WEP") == 0) || (strcmp(arg
, "wep") == 0))
3146 pAdapter
->PortCfg
.WepStatus
= Ndis802_11WEPEnabled
;
3147 else if ((strcmp(arg
, "TKIP") == 0) || (strcmp(arg
, "tkip") == 0))
3148 pAdapter
->PortCfg
.WepStatus
= Ndis802_11Encryption2Enabled
;
3149 else if ((strcmp(arg
, "AES") == 0) || (strcmp(arg
, "aes") == 0))
3150 pAdapter
->PortCfg
.WepStatus
= Ndis802_11Encryption3Enabled
;
3154 DBGPRINT(RT_DEBUG_TRACE
, "Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter
->PortCfg
.WepStatus
);
3159 ==========================================================================
3163 TRUE if all parameters are OK, FALSE otherwise
3164 ==========================================================================
3166 INT
Set_DefaultKeyID_Proc(
3167 IN PRTMP_ADAPTER pAdapter
,
3172 KeyIdx
= simple_strtol(arg
, 0, 10);
3173 if((KeyIdx
>= 1 ) && (KeyIdx
<= 4))
3174 pAdapter
->PortCfg
.DefaultKeyId
= (UCHAR
) (KeyIdx
- 1 );
3176 return FALSE
; //Invalid argument
3178 DBGPRINT(RT_DEBUG_TRACE
, "Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter
->PortCfg
.DefaultKeyId
);
3183 ==========================================================================
3187 TRUE if all parameters are OK, FALSE otherwise
3188 ==========================================================================
3191 IN PRTMP_ADAPTER pAdapter
,
3197 KeyLen
= strlen(arg
);
3201 case 5: //wep 40 Ascii type
3202 pAdapter
->PortCfg
.SharedKey
[0].KeyLen
= KeyLen
;
3203 memcpy(pAdapter
->PortCfg
.SharedKey
[0].Key
, arg
, KeyLen
);
3204 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg
, "Ascii");
3206 case 10: //wep 40 Hex type
3207 for(i
=0; i
< KeyLen
; i
++)
3209 if( !isxdigit(*(arg
+i
)) )
3210 return FALSE
; //Not Hex value;
3212 pAdapter
->PortCfg
.SharedKey
[0].KeyLen
= KeyLen
/ 2 ;
3213 AtoH(arg
, pAdapter
->PortCfg
.SharedKey
[0].Key
, KeyLen
/ 2);
3214 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg
, "Hex");
3216 case 13: //wep 104 Ascii type
3217 pAdapter
->PortCfg
.SharedKey
[0].KeyLen
= KeyLen
;
3218 memcpy(pAdapter
->PortCfg
.SharedKey
[0].Key
, arg
, KeyLen
);
3219 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg
, "Ascii");
3221 case 26: //wep 104 Hex type
3222 for(i
=0; i
< KeyLen
; i
++)
3224 if( !isxdigit(*(arg
+i
)) )
3225 return FALSE
; //Not Hex value;
3227 pAdapter
->PortCfg
.SharedKey
[0].KeyLen
= KeyLen
/ 2 ;
3228 AtoH(arg
, pAdapter
->PortCfg
.SharedKey
[0].Key
, KeyLen
/ 2);
3229 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key1_Proc::(Key1=%s and type=%s)\n", arg
, "Hex");
3231 default: //Invalid argument
3232 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key1_Proc::Invalid argument (=%s)\n", arg
);
3239 ==========================================================================
3243 TRUE if all parameters are OK, FALSE otherwise
3244 ==========================================================================
3247 IN PRTMP_ADAPTER pAdapter
,
3253 KeyLen
= strlen(arg
);
3257 case 5: //wep 40 Ascii type
3258 pAdapter
->PortCfg
.SharedKey
[1].KeyLen
= KeyLen
;
3259 memcpy(pAdapter
->PortCfg
.SharedKey
[1].Key
, arg
, KeyLen
);
3260 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key2_Proc::(Key2=%s and type=%s)\n", arg
, "Ascii");
3262 case 10: //wep 40 Hex type
3263 for(i
=0; i
< KeyLen
; i
++)
3265 if( !isxdigit(*(arg
+i
)) )
3266 return FALSE
; //Not Hex value;
3268 pAdapter
->PortCfg
.SharedKey
[1].KeyLen
= KeyLen
/ 2 ;
3269 AtoH(arg
, pAdapter
->PortCfg
.SharedKey
[1].Key
, KeyLen
/ 2);
3270 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key2_Proc::(Key2=%s and type=%s)\n", arg
, "Hex");
3272 case 13: //wep 104 Ascii type
3273 pAdapter
->PortCfg
.SharedKey
[1].KeyLen
= KeyLen
;
3274 memcpy(pAdapter
->PortCfg
.SharedKey
[1].Key
, arg
, KeyLen
);
3275 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key2_Proc::(Key2=%s and type=%s)\n", arg
, "Ascii");
3277 case 26: //wep 104 Hex type
3278 for(i
=0; i
< KeyLen
; i
++)
3280 if( !isxdigit(*(arg
+i
)) )
3281 return FALSE
; //Not Hex value;
3283 pAdapter
->PortCfg
.SharedKey
[1].KeyLen
= KeyLen
/ 2 ;
3284 AtoH(arg
, pAdapter
->PortCfg
.SharedKey
[1].Key
, KeyLen
/ 2);
3285 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key2_Proc::(Key2=%s and type=%s)\n", arg
, "Hex");
3287 default: //Invalid argument
3288 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key2_Proc::Invalid argument (=%s)\n", arg
);
3295 ==========================================================================
3299 TRUE if all parameters are OK, FALSE otherwise
3300 ==========================================================================
3303 IN PRTMP_ADAPTER pAdapter
,
3309 KeyLen
= strlen(arg
);
3313 case 5: //wep 40 Ascii type
3314 pAdapter
->PortCfg
.SharedKey
[2].KeyLen
= KeyLen
;
3315 memcpy(pAdapter
->PortCfg
.SharedKey
[2].Key
, arg
, KeyLen
);
3316 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key3_Proc::(Key3=%s and type=%s)\n", arg
, "Ascii");
3318 case 10: //wep 40 Hex type
3319 for(i
=0; i
< KeyLen
; i
++)
3321 if( !isxdigit(*(arg
+i
)) )
3322 return FALSE
; //Not Hex value;
3324 pAdapter
->PortCfg
.SharedKey
[2].KeyLen
= KeyLen
/ 2 ;
3325 AtoH(arg
, pAdapter
->PortCfg
.SharedKey
[2].Key
, KeyLen
/ 2);
3326 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key3_Proc::(Key3=%s and type=%s)\n", arg
, "Hex");
3328 case 13: //wep 104 Ascii type
3329 pAdapter
->PortCfg
.SharedKey
[2].KeyLen
= KeyLen
;
3330 memcpy(pAdapter
->PortCfg
.SharedKey
[2].Key
, arg
, KeyLen
);
3331 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key3_Proc::(Key3=%s and type=%s)\n", arg
, "Ascii");
3333 case 26: //wep 104 Hex type
3334 for(i
=0; i
< KeyLen
; i
++)
3336 if( !isxdigit(*(arg
+i
)) )
3337 return FALSE
; //Not Hex value;
3339 pAdapter
->PortCfg
.SharedKey
[2].KeyLen
= KeyLen
/ 2 ;
3340 AtoH(arg
, pAdapter
->PortCfg
.SharedKey
[2].Key
, KeyLen
/ 2);
3341 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key3_Proc::(Key3=%s and type=%s)\n", arg
, "Hex");
3343 default: //Invalid argument
3344 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key3_Proc::Invalid argument (=%s)\n", arg
);
3351 ==========================================================================
3355 TRUE if all parameters are OK, FALSE otherwise
3356 ==========================================================================
3359 IN PRTMP_ADAPTER pAdapter
,
3365 KeyLen
= strlen(arg
);
3369 case 5: //wep 40 Ascii type
3370 pAdapter
->PortCfg
.SharedKey
[3].KeyLen
= KeyLen
;
3371 memcpy(pAdapter
->PortCfg
.SharedKey
[3].Key
, arg
, KeyLen
);
3372 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key4_Proc::(Key4=%s and type=%s)\n", arg
, "Ascii");
3374 case 10: //wep 40 Hex type
3375 for(i
=0; i
< KeyLen
; i
++)
3377 if( !isxdigit(*(arg
+i
)) )
3378 return FALSE
; //Not Hex value;
3380 pAdapter
->PortCfg
.SharedKey
[3].KeyLen
= KeyLen
/ 2 ;
3381 AtoH(arg
, pAdapter
->PortCfg
.SharedKey
[3].Key
, KeyLen
/ 2);
3382 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key4_Proc::(Key4=%s and type=%s)\n", arg
, "Hex");
3384 case 13: //wep 104 Ascii type
3385 pAdapter
->PortCfg
.SharedKey
[3].KeyLen
= KeyLen
;
3386 memcpy(pAdapter
->PortCfg
.SharedKey
[3].Key
, arg
, KeyLen
);
3387 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key4_Proc::(Key4=%s and type=%s)\n", arg
, "Ascii");
3389 case 26: //wep 104 Hex type
3390 for(i
=0; i
< KeyLen
; i
++)
3392 if( !isxdigit(*(arg
+i
)) )
3393 return FALSE
; //Not Hex value;
3395 pAdapter
->PortCfg
.SharedKey
[3].KeyLen
= KeyLen
/ 2 ;
3396 AtoH(arg
, pAdapter
->PortCfg
.SharedKey
[3].Key
, KeyLen
/ 2);
3397 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key4_Proc::(Key4=%s and type=%s)\n", arg
, "Hex");
3399 default: //Invalid argument
3400 DBGPRINT(RT_DEBUG_TRACE
, "Set_Key4_Proc::Invalid argument (=%s)\n", arg
);
3407 ==========================================================================
3411 TRUE if all parameters are OK, FALSE otherwise
3412 ==========================================================================
3414 INT
Set_WPAPSK_Proc(
3415 IN PRTMP_ADAPTER pAdapter
,
3418 UCHAR keyMaterial
[40];
3420 DBGPRINT(RT_DEBUG_TRACE
, "Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg
);
3421 if ((strlen(arg
) < 8) || (strlen(arg
) > 64))
3423 DBGPRINT(RT_DEBUG_TRACE
, "Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg
);
3427 if (strlen(arg
) == 64)
3429 AtoH(arg
, pAdapter
->PortCfg
.PskKey
.Key
, 32);
3433 PasswordHash((char *)arg
, pAdapter
->Mlme
.CntlAux
.Ssid
, pAdapter
->Mlme
.CntlAux
.SsidLen
, keyMaterial
);
3435 NdisMoveMemory(pAdapter
->PortCfg
.PskKey
.Key
, keyMaterial
, 32);
3438 // Use RaConfig as PSK agent.
3439 // Start STA supplicant state machine
3440 pAdapter
->PortCfg
.WpaState
= SS_START
;
3447 ==========================================================================
3451 TRUE if all parameters are OK, FALSE otherwise
3452 ==========================================================================
3455 INT
Set_WPANONE_Proc(
3456 IN PRTMP_ADAPTER pAdapter
,
3459 UCHAR keyMaterial
[40];
3461 DBGPRINT(RT_DEBUG_TRACE
, "Set_WPANONE_Proc::(WPANONE=%s)\n", arg
);
3462 if ((strlen(arg
) < 8) || (strlen(arg
) > 64))
3464 DBGPRINT(RT_DEBUG_TRACE
, "Set failed!!(WPANONE=%s), WPANONE key-string required 8 ~ 64 characters \n", arg
);
3468 if (strlen(arg
) == 64)
3470 AtoH(arg
, pAdapter
->PortCfg
.PskKey
.Key
, 32);
3474 PasswordHash((char *)arg
, pAdapter
->Mlme
.CntlAux
.Ssid
, pAdapter
->Mlme
.CntlAux
.SsidLen
, keyMaterial
);
3476 NdisMoveMemory(pAdapter
->PortCfg
.PskKey
.Key
, keyMaterial
, 32);
3479 // Use RaConfig as PSK agent.
3480 // Start STA supplicant state machine
3481 pAdapter
->PortCfg
.WpaState
= SS_START
;
3483 //-----------------------------------------------------------------------------
3484 // pasted from "RTMPWPAAddKeyProc(...)"
3485 // major on Group Key only.
3489 // 3. Set as default Tx Key if bTxKey is TRUE
3490 pAdapter
->PortCfg
.DefaultKeyId
= 0;
3492 // 4. Selct RxMic / TxMic based on Supp / Authenticator
3493 // for WPA-None Tx, Rx MIC is the same
3494 //pTxMic = (PUCHAR) (keyMaterial) + 16;
3497 NdisZeroMemory(pAdapter
->PortCfg
.GroupKey
[0].RxTsc
, 6);
3499 // 6. Copy information into Group Key structure.
3500 // pKey->KeyLength will include TxMic and RxMic, therefore, we use 16 bytes hardcoded.
3501 pAdapter
->PortCfg
.GroupKey
[0].KeyLen
= 16;
3502 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[0].Key
, (PUCHAR
)(keyMaterial
) + 0,16);
3503 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[0].RxMic
, (PUCHAR
)(keyMaterial
) + 16, 8);
3504 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[0].TxMic
, (PUCHAR
)(keyMaterial
) + 16, 8);
3505 NdisMoveMemory(pAdapter
->PortCfg
.GroupKey
[0].BssId
, &pAdapter
->PortCfg
.Bssid
, 6);
3507 // Init TxTsc to one based on WiFi WPA specs
3508 pAdapter
->PortCfg
.GroupKey
[0].TxTsc
[0] = 1;
3509 pAdapter
->PortCfg
.GroupKey
[0].TxTsc
[1] = 0;
3510 pAdapter
->PortCfg
.GroupKey
[0].TxTsc
[2] = 0;
3511 pAdapter
->PortCfg
.GroupKey
[0].TxTsc
[3] = 0;
3512 pAdapter
->PortCfg
.GroupKey
[0].TxTsc
[4] = 0;
3513 pAdapter
->PortCfg
.GroupKey
[0].TxTsc
[5] = 0;
3515 // 802.1x port control
3516 pAdapter
->PortCfg
.PortSecured
= WPA_802_1X_PORT_SECURED
;
3522 ==========================================================================
3526 pAdapter Pointer to our adapter
3527 wrq Pointer to the ioctl argument
3534 1.) iwpriv ra0 bbp ==> read all BBP
3535 2.) iwpriv ra0 bbp 1,2,10,32 ==> raed BBP where ID=1,2,10,32
3536 3.) iwpriv ra0 bbp 1=10,17=3E ==> write BBP R1=0x10, R17=0x3E
3537 ==========================================================================
3540 IN PRTMP_ADAPTER pAdapter
,
3541 IN
struct iwreq
*wrq
)
3553 BOOLEAN bIsPrintAllBBP
= FALSE
;
3556 DBGPRINT(RT_DEBUG_TRACE
, "==>RTMPIoctlBBP\n");
3557 memset(msg
, 0x00, 1024);
3558 if (wrq
->u
.data
.length
> 1) //No parameters.
3560 memcpy(arg
, wrq
->u
.data
.pointer
, (wrq
->u
.data
.length
> 255) ? 255 : wrq
->u
.data
.length
);
3563 //Parsing Read or Write
3564 while ((this_char
= strsep(&ptr
, ",")) != NULL
)
3567 DBGPRINT(RT_DEBUG_TRACE
, "this_char=%s\n", this_char
);
3571 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
3574 if (!value
|| !*value
)
3576 DBGPRINT(RT_DEBUG_TRACE
, "this_char=%s, value=%s\n", this_char
, value
);
3577 bbpId
= simple_strtol(this_char
, 0, 10);
3578 if ((bbpId
>=0) && (bbpId
<= 63))
3580 RTMP_BBP_IO_READ32_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
3581 sprintf(msg
+strlen(msg
), "R%02d[0x%02X]:%02X ", bbpId
, bbpId
*2, regBBP
);
3584 sprintf(msg
+strlen(msg
), "\n");
3585 DBGPRINT(RT_DEBUG_TRACE
, "msg=%s\n", msg
);
3588 {//Invalid parametes, so default print all bbp
3589 bIsPrintAllBBP
= TRUE
;
3595 DBGPRINT(RT_DEBUG_TRACE
, "this_char=%s, value=%s\n", this_char
, value
);
3596 bbpId
= simple_strtol(this_char
, 0, 10);
3597 bbpValue
= simple_strtol(value
, 0, 10);
3598 DBGPRINT(RT_DEBUG_TRACE
, "bbpID=%02d, value=0x%x\n", bbpId
, bbpValue
);
3599 if ((bbpId
>=0) && (bbpId
<= 63))
3601 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter
, (UCHAR
) bbpId
, (UCHAR
) bbpValue
);
3602 //Read it back for showing
3603 RTMP_BBP_IO_READ32_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
3604 sprintf(msg
+strlen(msg
), "R%02d[0x%02X]:%02X ", bbpId
, bbpId
*2, regBBP
);
3607 sprintf(msg
+strlen(msg
), "\n");
3608 DBGPRINT(RT_DEBUG_TRACE
, "msg=%s\n", msg
);
3611 {//Invalid parametes, so default print all bbp
3612 bIsPrintAllBBP
= TRUE
;
3619 bIsPrintAllBBP
= TRUE
;
3623 memset(msg
, 0x00, 1024);
3625 for (i
= 0; i
<= 63; i
++)
3627 RTMP_BBP_IO_READ32_BY_REG_ID(pAdapter
, i
, ®BBP
);
3628 sprintf(msg
+strlen(msg
), "R%02d[0x%02X]:%02X ", i
, i
*2, regBBP
);
3630 sprintf(msg
+strlen(msg
), "\n");
3632 // Copy the information into the user buffer
3633 wrq
->u
.data
.length
= strlen(msg
);
3634 Status
= copy_to_user(wrq
->u
.data
.pointer
, msg
, wrq
->u
.data
.length
);
3638 DBGPRINT(RT_DEBUG_TRACE
, "copy to user [msg=%s]\n", msg
);
3639 // Copy the information into the user buffer
3640 wrq
->u
.data
.length
= strlen(msg
);
3641 Status
= copy_to_user(wrq
->u
.data
.pointer
, msg
, wrq
->u
.data
.length
);
3643 DBGPRINT(RT_DEBUG_TRACE
, "<==RTMPIoctlBBP\n");
3647 ==========================================================================
3651 pAdapter Pointer to our adapter
3652 wrq Pointer to the ioctl argument
3659 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
3660 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
3661 ==========================================================================
3664 IN PRTMP_ADAPTER pAdapter
,
3665 IN
struct iwreq
*wrq
)
3675 UCHAR temp
[16], temp2
[16];
3679 DBGPRINT(RT_DEBUG_TRACE
, "==>RTMPIoctlMAC\n");
3680 memset(msg
, 0x00, 1024);
3681 if (wrq
->u
.data
.length
> 1) //No parameters.
3683 memcpy(arg
, wrq
->u
.data
.pointer
, (wrq
->u
.data
.length
> 255) ? 255 : wrq
->u
.data
.length
);
3686 //Parsing Read or Write
3687 while ((this_char
= strsep(&ptr
, ",")) != NULL
)
3689 DBGPRINT(RT_DEBUG_TRACE
, "this_char=%s\n", this_char
);
3693 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
3696 if (!value
|| !*value
)
3699 if(strlen(this_char
) > 4)
3702 j
= strlen(this_char
);
3705 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
3710 k
= j
= strlen(this_char
);
3713 this_char
[4-k
+j
] = this_char
[j
];
3717 this_char
[3-k
++]='0';
3720 if(strlen(this_char
) == 4)
3722 AtoH(this_char
, temp
, 4);
3723 macAddr
= *temp
*256 + temp
[1];
3724 if (macAddr
< 0xFFFF)
3726 RTMP_IO_READ32(pAdapter
, macAddr
, &macValue
);
3727 DBGPRINT(RT_DEBUG_TRACE
, "macAddr=%x, regMAC=%x\n", macAddr
, macValue
);
3728 sprintf(msg
+strlen(msg
), "[0x%08X]:%08X ", macAddr
, macValue
);
3731 sprintf(msg
+strlen(msg
), "\n");
3732 DBGPRINT(RT_DEBUG_TRACE
, "msg=%s\n", msg
);
3735 {//Invalid parametes, so default print all bbp
3742 memcpy(&temp2
, value
, strlen(value
));
3743 temp2
[strlen(value
)] = '\0';
3746 if((strlen(this_char
) > 4) || strlen(temp2
) > 8)
3749 j
= strlen(this_char
);
3752 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
3759 if(temp2
[j
] > 'f' || temp2
[j
] < '0')
3764 k
= j
= strlen(this_char
);
3767 this_char
[4-k
+j
] = this_char
[j
];
3771 this_char
[3-k
++]='0';
3775 k
= j
= strlen(temp2
);
3778 temp2
[8-k
+j
] = temp2
[j
];
3786 AtoH(this_char
, temp
, 4);
3787 macAddr
= *temp
*256 + temp
[1];
3789 AtoH(temp2
, temp
, 8);
3790 macValue
= *temp
*256*256*256 + temp
[1]*256*256 + temp
[2]*256 + temp
[3];
3792 DBGPRINT(RT_DEBUG_TRACE
, "macAddr=%02x, macValue=0x%x\n", macAddr
, macValue
);
3794 RTMP_IO_WRITE32(pAdapter
, macAddr
, macValue
);
3795 sprintf(msg
+strlen(msg
), "[0x%02X]:%02X ", macAddr
, macValue
);
3798 sprintf(msg
+strlen(msg
), "\n");
3799 DBGPRINT(RT_DEBUG_TRACE
, "msg=%s\n", msg
);
3805 if(strlen(msg
) == 1)
3806 sprintf(msg
+strlen(msg
), "===>Error command format!");
3807 DBGPRINT(RT_DEBUG_TRACE
, "copy to user [msg=%s]\n", msg
);
3808 // Copy the information into the user buffer
3809 wrq
->u
.data
.length
= strlen(msg
);
3810 Status
= copy_to_user(wrq
->u
.data
.pointer
, msg
, wrq
->u
.data
.length
);
3812 DBGPRINT(RT_DEBUG_TRACE
, "<==RTMPIoctlMAC\n");
3817 ==========================================================================
3821 pAdapter Pointer to our adapter
3822 wrq Pointer to the ioctl argument
3829 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
3830 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
3831 ==========================================================================
3833 VOID
RTMPIoctlE2PROM(
3834 IN PRTMP_ADAPTER pAdapter
,
3835 IN
struct iwreq
*wrq
)
3845 UCHAR temp
[16], temp2
[16];
3849 DBGPRINT(RT_DEBUG_TRACE
, "==>RTMPIoctlE2PROM\n");
3850 memset(msg
, 0x00, 1024);
3851 if (wrq
->u
.data
.length
> 1) //No parameters.
3853 memcpy(arg
, wrq
->u
.data
.pointer
, (wrq
->u
.data
.length
> 255) ? 255 : wrq
->u
.data
.length
);
3856 //Parsing Read or Write
3857 while ((this_char
= strsep(&ptr
, ",")) != NULL
)
3859 DBGPRINT(RT_DEBUG_TRACE
, "this_char=%s\n", this_char
);
3863 if ((value
= strchr(this_char
, '=')) != NULL
)
3866 if (!value
|| !*value
)
3868 DBGPRINT(RT_DEBUG_TRACE
, "Read: this_char=%s, strlen=%d\n", this_char
, strlen(this_char
));
3871 if(strlen(this_char
) > 4)
3874 j
= strlen(this_char
);
3877 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
3882 k
= j
= strlen(this_char
);
3885 this_char
[4-k
+j
] = this_char
[j
];
3889 this_char
[3-k
++]='0';
3892 if(strlen(this_char
) == 4)
3894 AtoH(this_char
, temp
, 4);
3895 eepAddr
= *temp
*256 + temp
[1];
3896 if (eepAddr
< 0xFFFF)
3898 eepValue
= RTMP_EEPROM_READ16(pAdapter
, eepAddr
);
3899 DBGPRINT(RT_DEBUG_TRACE
, "eepAddr=%x, eepValue=%x\n", eepAddr
, eepValue
);
3900 sprintf(msg
+strlen(msg
), "[0x%04X]:%04X ", eepAddr
, eepValue
);
3903 sprintf(msg
+strlen(msg
), "\n");
3904 DBGPRINT(RT_DEBUG_TRACE
, "msg=%s\n", msg
);
3907 {//Invalid parametes, so default printk all bbp
3914 DBGPRINT(RT_DEBUG_TRACE
, "Write: this_char=%s, strlen(value)=%d, value=%s\n", this_char
, strlen(value
), value
);
3915 memcpy(&temp2
, value
, strlen(value
));
3916 temp2
[strlen(value
)] = '\0';
3919 if((strlen(this_char
) > 4) || strlen(temp2
) > 8)
3922 j
= strlen(this_char
);
3925 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
3931 if(temp2
[j
] > 'f' || temp2
[j
] < '0')
3936 k
= j
= strlen(this_char
);
3939 this_char
[4-k
+j
] = this_char
[j
];
3943 this_char
[3-k
++]='0';
3947 k
= j
= strlen(temp2
);
3950 temp2
[4-k
+j
] = temp2
[j
];
3957 AtoH(this_char
, temp
, 4);
3958 eepAddr
= *temp
*256 + temp
[1];
3960 AtoH(temp2
, temp
, 4);
3961 eepValue
= *temp
*256 + temp
[1];
3963 DBGPRINT(RT_DEBUG_TRACE
, "eepAddr=%02x, eepValue=0x%x\n", eepAddr
, eepValue
);
3965 RTMP_EEPROM_WRITE16(pAdapter
, eepAddr
, eepValue
);
3966 sprintf(msg
+strlen(msg
), "[0x%02X]:%02X ", eepAddr
, eepValue
);
3969 sprintf(msg
+strlen(msg
), "\n");
3970 DBGPRINT(RT_DEBUG_TRACE
, "msg=%s\n", msg
);
3975 if(strlen(msg
) == 1)
3976 sprintf(msg
+strlen(msg
), "===>Error command format!");
3978 // Copy the information into the user buffer
3979 DBGPRINT(RT_DEBUG_TRACE
, "copy to user [msg=%s]\n", msg
);
3980 wrq
->u
.data
.length
= strlen(msg
);
3981 Status
= copy_to_user(wrq
->u
.data
.pointer
, msg
, wrq
->u
.data
.length
);
3983 DBGPRINT(RT_DEBUG_TRACE
, "<==RTMPIoctlE2PROM\n");
3986 UCHAR TempletFrame
[24] = {0x08,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00}; // 802.11 MAC Header, Type:Data, Length:24bytes
3989 ==========================================================================
3991 Set ATE operation mode to
3992 0. STASTOP = Stop STA Mode
3993 1. STASTART = Start STA Mode
3994 2. TXCONT = Continuous Transmit
3995 3. TXCARR = Transmit Carrier
3996 4. TXFRAME = Transmit Frames
3997 5. RXFRAME = Receive Frames
3999 TRUE if all parameters are OK, FALSE otherwise
4000 ==========================================================================
4003 IN PRTMP_ADAPTER pAdapter
,
4012 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_Proc (arg = %s)\n", arg
);
4016 AsicSwitchChannel(pAdapter
, pAdapter
->ate
.Channel
);
4017 AsicLockChannel(pAdapter
, pAdapter
->ate
.Channel
);
4021 RTMP_BBP_IO_READ32_BY_REG_ID(pAdapter
, 63, &BbpData
);
4022 RTMP_IO_READ32(pAdapter
, MACCSR1
, &MacData
);
4025 MacData
&= 0xFBFFFFFF;
4027 if (!strcmp(arg
, "STASTOP"))
4029 DBGPRINT(RT_DEBUG_TRACE
, "ATE: STASTOP\n");
4031 RTMP_IO_WRITE32(pAdapter
, MACCSR1
, MacData
);
4032 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter
, 63, BbpData
);
4034 pAdapter
->ate
.Mode
= ATE_STASTOP
;
4037 AsicEnableBssSync(pAdapter
);
4038 netif_stop_queue(pAdapter
->net_dev
);
4039 RTMPStationStop(pAdapter
);
4040 RTMP_IO_WRITE32(pAdapter
, RXCSR0
, 0xffffffff); // Stop Rx
4042 else if (!strcmp(arg
, "STASTART"))
4044 DBGPRINT(RT_DEBUG_TRACE
, "ATE: STASTART\n");
4046 RTMP_IO_WRITE32(pAdapter
, MACCSR1
, MacData
);
4047 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter
, 63, BbpData
);
4049 pAdapter
->ate
.Mode
= ATE_STASTART
;
4051 RTMP_IO_WRITE32(pAdapter
, RXCSR0
, 0x56); // Start Rx
4052 netif_start_queue(pAdapter
->net_dev
);
4053 RTMPStationStart(pAdapter
);
4055 else if (!strcmp(arg
, "TXCONT")) // Continuous Tx
4057 DBGPRINT(RT_DEBUG_TRACE
, "ATE: TXCONT\n");
4059 pAdapter
->ate
.Mode
= ATE_TXCONT
;
4062 MacData
|= 0x04000000;
4064 RTMP_IO_WRITE32(pAdapter
, MACCSR1
, MacData
);
4065 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter
, 63, BbpData
);
4067 for (i
= 0; (i
< TX_RING_SIZE
) && (i
< pAdapter
->ate
.TxCount
); i
++)
4069 pTxD
= (PTXD_STRUC
)pAdapter
->TxRing
[pAdapter
->CurEncryptIndex
].va_addr
;
4070 pDest
= (PUCHAR
) pAdapter
->TxRing
[pAdapter
->CurEncryptIndex
].va_data_addr
;
4072 // Prepare frame payload
4073 memcpy(pDest
, &TempletFrame
, LENGTH_802_11
);
4074 for(j
= LENGTH_802_11
; j
< pAdapter
->ate
.TxLength
; j
++)
4076 memcpy(&pDest
[4], &pAdapter
->ate
.Addr1
, ETH_LENGTH_OF_ADDRESS
);
4077 memcpy(&pDest
[10], &pAdapter
->ate
.Addr2
, ETH_LENGTH_OF_ADDRESS
);
4078 memcpy(&pDest
[16], &pAdapter
->ate
.Addr3
, ETH_LENGTH_OF_ADDRESS
);
4080 RTMPWriteTxDescriptor(pTxD
, TRUE
, CIPHER_NONE
, FALSE
, FALSE
, FALSE
,
4081 SHORT_RETRY
, IFS_BACKOFF
, pAdapter
->ate
.TxRate
, 4,
4082 pAdapter
->ate
.TxLength
, pAdapter
->PortCfg
.TxPreambleInUsed
, 0);
4084 pAdapter
->CurEncryptIndex
++;
4085 if (pAdapter
->CurEncryptIndex
>= TX_RING_SIZE
)
4087 pAdapter
->CurEncryptIndex
= 0;
4091 RTMP_IO_WRITE32(pAdapter
, RXCSR0
, 0xffffffff);
4092 RTMP_IO_WRITE32(pAdapter
, SECCSR1
, 0x1);
4094 else if (!strcmp(arg
, "TXCARR")) // Tx Carrier -------------------------------------
4096 DBGPRINT(RT_DEBUG_TRACE
, "ATE: TXCARR\n");
4097 pAdapter
->ate
.Mode
= ATE_TXCARR
;
4100 MacData
|= 0x04000000;
4102 RTMP_IO_WRITE32(pAdapter
, MACCSR1
, MacData
);
4103 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter
, 63, BbpData
);
4105 for (i
= 0; (i
< TX_RING_SIZE
) && (i
< pAdapter
->ate
.TxCount
); i
++)
4107 pTxD
= (PTXD_STRUC
)pAdapter
->TxRing
[pAdapter
->CurEncryptIndex
].va_addr
;
4108 pDest
= (PUCHAR
) pAdapter
->TxRing
[pAdapter
->CurEncryptIndex
].va_data_addr
;
4110 // Prepare frame payload
4111 memcpy(pDest
, &TempletFrame
, LENGTH_802_11
);
4112 for(j
= LENGTH_802_11
; j
< pAdapter
->ate
.TxLength
; j
++)
4114 memcpy(&pDest
[4], &pAdapter
->ate
.Addr1
, ETH_LENGTH_OF_ADDRESS
);
4115 memcpy(&pDest
[10], &pAdapter
->ate
.Addr2
, ETH_LENGTH_OF_ADDRESS
);
4116 memcpy(&pDest
[16], &pAdapter
->ate
.Addr3
, ETH_LENGTH_OF_ADDRESS
);
4118 RTMPWriteTxDescriptor(pTxD
, TRUE
, CIPHER_NONE
, FALSE
, FALSE
, FALSE
,
4119 SHORT_RETRY
, IFS_BACKOFF
, pAdapter
->ate
.TxRate
, 4,
4120 pAdapter
->ate
.TxLength
, pAdapter
->PortCfg
.TxPreambleInUsed
, 0);
4122 pAdapter
->CurEncryptIndex
++;
4123 if (pAdapter
->CurEncryptIndex
>= TX_RING_SIZE
)
4125 pAdapter
->CurEncryptIndex
= 0;
4129 RTMP_IO_WRITE32(pAdapter
, RXCSR0
, 0xffffffff);
4130 RTMP_IO_WRITE32(pAdapter
, SECCSR1
, 0x1);
4132 else if (!strcmp(arg
, "TXFRAME")) // Tx Frames --------------------------------------
4134 DBGPRINT(RT_DEBUG_TRACE
, "ATE: TXFRAME(Count=%d)\n", pAdapter
->ate
.TxCount
);
4135 pAdapter
->ate
.Mode
= ATE_TXFRAME
;
4137 RTMP_IO_WRITE32(pAdapter
, MACCSR1
, MacData
);
4138 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter
, 63, BbpData
);
4140 pAdapter
->ate
.TxDoneCount
= 0;
4142 for (i
= 0; (i
< TX_RING_SIZE
) && (i
< pAdapter
->ate
.TxCount
); i
++)
4144 pTxD
= (PTXD_STRUC
)pAdapter
->TxRing
[pAdapter
->CurEncryptIndex
].va_addr
;
4145 pDest
= (PUCHAR
) pAdapter
->TxRing
[pAdapter
->CurEncryptIndex
].va_data_addr
;
4147 // Prepare frame payload
4148 memcpy(pDest
, &TempletFrame
, LENGTH_802_11
);
4149 for(j
= LENGTH_802_11
; j
< pAdapter
->ate
.TxLength
; j
++)
4151 memcpy(&pDest
[4], &pAdapter
->ate
.Addr1
, ETH_LENGTH_OF_ADDRESS
);
4152 memcpy(&pDest
[10], &pAdapter
->ate
.Addr2
, ETH_LENGTH_OF_ADDRESS
);
4153 memcpy(&pDest
[16], &pAdapter
->ate
.Addr3
, ETH_LENGTH_OF_ADDRESS
);
4155 RTMPWriteTxDescriptor(pTxD
, TRUE
, CIPHER_NONE
, FALSE
, FALSE
, FALSE
,
4156 SHORT_RETRY
, IFS_BACKOFF
, pAdapter
->ate
.TxRate
, 4,
4157 pAdapter
->ate
.TxLength
, Rt802_11PreambleLong
, 0);
4159 pAdapter
->CurEncryptIndex
++;
4160 if (pAdapter
->CurEncryptIndex
>= TX_RING_SIZE
)
4162 pAdapter
->CurEncryptIndex
= 0;
4165 pAdapter
->ate
.TxDoneCount
+= i
;
4166 DBGPRINT(RT_DEBUG_TRACE
, "TXFRAME txcount=%d\n", pAdapter
->ate
.TxCount
);
4167 DBGPRINT(RT_DEBUG_TRACE
, "pAdapter->ate.TxDoneCount = %d\n", pAdapter
->ate
.TxDoneCount
);
4169 RTMP_IO_WRITE32(pAdapter
, RXCSR0
, 0xffffffff);
4170 RTMP_IO_WRITE32(pAdapter
, SECCSR1
, 0x1);
4172 else if (!strcmp(arg
, "RXFRAME")) // Rx Frames --------------------------------------
4174 DBGPRINT(RT_DEBUG_TRACE
, "ATE: RXFRAME\n");
4176 RTMP_IO_WRITE32(pAdapter
, MACCSR1
, MacData
);
4177 RTMP_BBP_IO_WRITE32_BY_REG_ID(pAdapter
, 63, BbpData
);
4179 pAdapter
->ate
.Mode
= ATE_RXFRAME
;
4180 pAdapter
->ate
.TxDoneCount
= pAdapter
->ate
.TxCount
;
4182 RTMP_IO_WRITE32(pAdapter
, TXCSR0
, 0x08); // Abort Tx
4183 RTMP_IO_WRITE32(pAdapter
, RXCSR0
, 0x56); // Start Rx
4187 DBGPRINT(RT_DEBUG_TRACE
, "ATE: Invalid arg!\n");
4192 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_Proc\n");
4197 ==========================================================================
4199 Set ATE ADDR1=DA for TxFrames Return:
4200 TRUE if all parameters are OK, FALSE otherwise
4201 ==========================================================================
4203 INT
Set_ATE_DA_Proc(
4204 IN PRTMP_ADAPTER pAdapter
,
4210 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_DA_Proc\n");
4211 DBGPRINT(RT_DEBUG_TRACE
, "arg=%s\n", arg
);
4213 if(strlen(arg
) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
4216 for (i
=0, value
= strtok(arg
,":"); value
; value
= strtok(NULL
,":"))
4218 if((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))) )
4219 return FALSE
; //Invalid
4221 AtoH(value
, &pAdapter
->ate
.Addr1
[i
++], 2);
4225 return FALSE
; //Invalid
4227 DBGPRINT(RT_DEBUG_TRACE
, "DA=%2X:%2X:%2X:%2X:%2X:%2X\n", pAdapter
->ate
.Addr1
[0], pAdapter
->ate
.Addr1
[1], pAdapter
->ate
.Addr1
[2], pAdapter
->ate
.Addr1
[3], pAdapter
->ate
.Addr1
[4], pAdapter
->ate
.Addr1
[5]);
4228 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_DA_Proc\n");
4234 ==========================================================================
4236 Set ATE ADDR2=SA for TxFrames Return:
4237 TRUE if all parameters are OK, FALSE otherwise
4238 ==========================================================================
4240 INT
Set_ATE_SA_Proc(
4241 IN PRTMP_ADAPTER pAdapter
,
4247 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_SA_Proc\n");
4248 DBGPRINT(RT_DEBUG_TRACE
, "arg=%s\n", arg
);
4250 if(strlen(arg
) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
4253 for (i
=0, value
= strtok(arg
,":"); value
; value
= strtok(NULL
,":"))
4255 if((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))) )
4256 return FALSE
; //Invalid
4258 AtoH(value
, &pAdapter
->ate
.Addr2
[i
++], 2);
4262 return FALSE
; //Invalid
4264 DBGPRINT(RT_DEBUG_TRACE
, "DA=%2X:%2X:%2X:%2X:%2X:%2X\n", pAdapter
->ate
.Addr2
[0], pAdapter
->ate
.Addr2
[1], pAdapter
->ate
.Addr2
[2], pAdapter
->ate
.Addr2
[3], pAdapter
->ate
.Addr2
[4], pAdapter
->ate
.Addr2
[5]);
4265 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_SA_Proc\n");
4271 ==========================================================================
4273 Set ATE ADDR3=BSSID for TxFrames Return:
4274 TRUE if all parameters are OK, FALSE otherwise
4275 ==========================================================================
4277 INT
Set_ATE_BSSID_Proc(
4278 IN PRTMP_ADAPTER pAdapter
,
4284 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_BSSID_Proc\n");
4285 DBGPRINT(RT_DEBUG_TRACE
, "arg=%s\n", arg
);
4287 if(strlen(arg
) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
4290 for (i
=0, value
= strtok(arg
,":"); value
; value
= strtok(NULL
,":"))
4292 if((strlen(value
) != 2) || (!isxdigit(*value
)) || (!isxdigit(*(value
+1))) )
4293 return FALSE
; //Invalid
4295 AtoH(value
, &pAdapter
->ate
.Addr3
[i
++], 2);
4299 return FALSE
; //Invalid
4301 DBGPRINT(RT_DEBUG_TRACE
, "DA=%2X:%2X:%2X:%2X:%2X:%2X\n", pAdapter
->ate
.Addr3
[0], pAdapter
->ate
.Addr3
[1], pAdapter
->ate
.Addr3
[2], pAdapter
->ate
.Addr3
[3], pAdapter
->ate
.Addr3
[4], pAdapter
->ate
.Addr3
[5]);
4302 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_BSSID_Proc\n");
4308 ==========================================================================
4310 Set ATE Channel Return:
4311 TRUE if all parameters are OK, FALSE otherwise
4312 ==========================================================================
4314 INT
Set_ATE_CHANNEL_Proc(
4315 IN PRTMP_ADAPTER pAdapter
,
4318 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_CHANNEL_Proc (arg = %s)\n", arg
);
4320 pAdapter
->ate
.Channel
= simple_strtol(arg
, 0, 10);
4322 if((pAdapter
->ate
.Channel
< 1) || (pAdapter
->ate
.Channel
> 14))
4324 pAdapter
->ate
.Channel
= 1;
4328 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_CHANNEL_Proc (ATE Channel = %d)\n", pAdapter
->ate
.Channel
);
4334 ==========================================================================
4336 Set ATE Tx Power Return:
4337 TRUE if all parameters are OK, FALSE otherwise
4338 ==========================================================================
4340 INT
Set_ATE_TX_POWER_Proc(
4341 IN PRTMP_ADAPTER pAdapter
,
4346 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_TX_POWER_Proc\n");
4347 DBGPRINT(RT_DEBUG_TRACE
, "arg=%s\n", arg
);
4349 pAdapter
->ate
.TxPower
= simple_strtol(arg
, 0, 10);
4351 if(pAdapter
->ate
.TxPower
>= 32)
4353 pAdapter
->ate
.TxPower
= pAdapter
->PortCfg
.ChannelTxPower
[pAdapter
->PortCfg
.Channel
- 1];;
4357 R3
= pAdapter
->ate
.TxPower
;
4358 R3
= R3
<< 9; // shift TX power control to correct RF register bit position
4360 R3
|= (pAdapter
->PortCfg
.LatchRfRegs
.R3
& 0xffffc1ff);
4361 RTMP_RF_IO_WRITE32(pAdapter
, R3
);
4363 DBGPRINT(RT_DEBUG_TRACE
, "TxPower = %d\n", pAdapter
->ate
.TxPower
);
4364 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_TX_POWER_Proc\n");
4370 ==========================================================================
4372 Set ATE Tx Length Return:
4373 TRUE if all parameters are OK, FALSE otherwise
4374 ==========================================================================
4376 INT
Set_ATE_TX_LENGTH_Proc(
4377 IN PRTMP_ADAPTER pAdapter
,
4380 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_TX_LENGTH_Proc\n");
4381 DBGPRINT(RT_DEBUG_TRACE
, "arg=%s\n", arg
);
4383 pAdapter
->ate
.TxLength
= simple_strtol(arg
, 0, 10);
4385 if((pAdapter
->ate
.TxLength
< 24) || (pAdapter
->ate
.TxLength
> 1500))
4387 pAdapter
->ate
.TxLength
= 1500;
4391 DBGPRINT(RT_DEBUG_TRACE
, "TxLength = %d\n", pAdapter
->ate
.TxLength
);
4392 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_TX_LENGTH_Proc\n");
4398 ==========================================================================
4400 Set ATE Tx Count Return:
4401 TRUE if all parameters are OK, FALSE otherwise
4402 ==========================================================================
4404 INT
Set_ATE_TX_COUNT_Proc(
4405 IN PRTMP_ADAPTER pAdapter
,
4408 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_TX_COUNT_Proc\n");
4409 DBGPRINT(RT_DEBUG_TRACE
, "arg=%s\n", arg
);
4411 pAdapter
->ate
.TxCount
= simple_strtol(arg
, 0, 10);
4413 DBGPRINT(RT_DEBUG_TRACE
, "TxCount = %d\n", pAdapter
->ate
.TxCount
);
4414 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_TX_COUNT_Proc\n");
4420 ==========================================================================
4424 TRUE if all parameters are OK, FALSE otherwise
4425 ==========================================================================
4427 INT
Set_ATE_TX_RATE_Proc(
4428 IN PRTMP_ADAPTER pAdapter
,
4431 DBGPRINT(RT_DEBUG_TRACE
, "==> Set_ATE_TX_RATE_Proc\n");
4432 DBGPRINT(RT_DEBUG_TRACE
, "arg=%s\n", arg
);
4434 pAdapter
->ate
.TxRate
= simple_strtol(arg
, 0, 10);
4436 if(pAdapter
->ate
.TxRate
> RATE_54
)
4438 pAdapter
->ate
.TxRate
= RATE_11
;
4442 DBGPRINT(RT_DEBUG_TRACE
, "TxRate = %d\n", pAdapter
->ate
.TxRate
);
4443 DBGPRINT(RT_DEBUG_TRACE
, "<== Set_ATE_TX_RATE_Proc\n");
4448 VOID
RTMPStationStop(
4449 IN PRTMP_ADAPTER pAd
)
4451 DBGPRINT(RT_DEBUG_TRACE
, "==> RTMPStationStop\n");
4452 RTMPCancelTimer(&pAd
->timer
);
4453 RTMPCancelTimer(&pAd
->Mlme
.AssocAux
.AssocTimer
);
4454 RTMPCancelTimer(&pAd
->Mlme
.AssocAux
.ReassocTimer
);
4455 RTMPCancelTimer(&pAd
->Mlme
.AssocAux
.DisassocTimer
);
4456 RTMPCancelTimer(&pAd
->Mlme
.AuthAux
.AuthTimer
);
4457 RTMPCancelTimer(&pAd
->Mlme
.AuthRspAux
.AuthRspTimer
);
4458 RTMPCancelTimer(&pAd
->Mlme
.SyncAux
.BeaconTimer
);
4459 RTMPCancelTimer(&pAd
->Mlme
.SyncAux
.ScanTimer
);
4460 RTMPCancelTimer(&pAd
->Mlme
.PeriodicTimer
);
4461 RTMPCancelTimer(&pAd
->PortCfg
.RfTuningTimer
);
4462 if (pAd
->PortCfg
.LedMode
== LED_MODE_TXRX_ACTIVITY
)
4463 RTMPCancelTimer(&pAd
->PortCfg
.LedCntl
.BlinkTimer
);
4464 RTMPCancelTimer(&pAd
->PortCfg
.RxAnt
.RxAntDiversityTimer
);
4465 DBGPRINT(RT_DEBUG_TRACE
, "<== RTMPStationStop\n");
4468 VOID
RTMPStationStart(
4469 IN PRTMP_ADAPTER pAd
)
4471 DBGPRINT(RT_DEBUG_TRACE
, "==> RTMPStationStart\n");
4472 RTMPSetTimer(pAd
, &pAd
->Mlme
.PeriodicTimer
, MLME_TASK_EXEC_INTV
);
4473 //RTMPSetTimer(pAd, &pAd->timer, DEBUG_TASK_DELAY); //not used.
4474 DBGPRINT(RT_DEBUG_TRACE
, "<== RTMPStationStart\n");
4477 #endif //#ifdef RALINK_ATE