root/drivers/staging/rtl8712/rtl871x_mp_ioctl.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. oid_null_function
  2. oid_rt_wireless_mode_hdl
  3. oid_rt_pro_write_bb_reg_hdl
  4. oid_rt_pro_read_bb_reg_hdl
  5. oid_rt_pro_write_rf_reg_hdl
  6. oid_rt_pro_read_rf_reg_hdl
  7. mp_start_test
  8. mp_stop_test
  9. oid_rt_pro_set_data_rate_hdl
  10. oid_rt_pro_start_test_hdl
  11. oid_rt_pro_stop_test_hdl
  12. oid_rt_pro_set_channel_direct_call_hdl
  13. oid_rt_pro_set_antenna_bb_hdl
  14. oid_rt_pro_set_tx_power_control_hdl
  15. oid_rt_pro_query_tx_packet_sent_hdl
  16. oid_rt_pro_query_rx_packet_received_hdl
  17. oid_rt_pro_query_rx_packet_crc32_error_hdl
  18. oid_rt_pro_reset_tx_packet_sent_hdl
  19. oid_rt_pro_reset_rx_packet_received_hdl
  20. oid_rt_reset_phy_rx_packet_count_hdl
  21. oid_rt_get_phy_rx_packet_received_hdl
  22. oid_rt_get_phy_rx_packet_crc32_error_hdl
  23. oid_rt_pro_set_modulation_hdl
  24. oid_rt_pro_set_continuous_tx_hdl
  25. oid_rt_pro_set_single_carrier_tx_hdl
  26. oid_rt_pro_set_carrier_suppression_tx_hdl
  27. oid_rt_pro_set_single_tone_tx_hdl
  28. oid_rt_pro_read_register_hdl
  29. oid_rt_pro_write_register_hdl
  30. oid_rt_get_thermal_meter_hdl
  31. oid_rt_pro_read_efuse_hdl
  32. oid_rt_pro_write_efuse_hdl
  33. oid_rt_get_efuse_current_size_hdl
  34. oid_rt_get_efuse_max_size_hdl
  35. oid_rt_pro_efuse_hdl
  36. oid_rt_pro_efuse_map_hdl
  37. oid_rt_set_bandwidth_hdl
  38. oid_rt_set_rx_packet_type_hdl
  39. mp_ioctl_xmit_packet_hdl
  40. oid_rt_set_power_down_hdl
  41. oid_rt_get_power_mode_hdl

   1 // SPDX-License-Identifier: GPL-2.0
   2 /******************************************************************************
   3  * rtl871x_mp_ioctl.c
   4  *
   5  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
   6  * Linux device driver for RTL8192SU
   7  *
   8  * Modifications for inclusion into the Linux staging tree are
   9  * Copyright(c) 2010 Larry Finger. All rights reserved.
  10  *
  11  * Contact information:
  12  * WLAN FAE <wlanfae@realtek.com>
  13  * Larry Finger <Larry.Finger@lwfinger.net>
  14  *
  15  ******************************************************************************/
  16 
  17 #include <linux/rndis.h>
  18 #include "osdep_service.h"
  19 #include "drv_types.h"
  20 #include "mlme_osdep.h"
  21 #include "rtl871x_mp.h"
  22 #include "rtl871x_mp_ioctl.h"
  23 
  24 uint oid_null_function(struct oid_par_priv *poid_par_priv)
  25 {
  26         return RNDIS_STATUS_SUCCESS;
  27 }
  28 
  29 uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv)
  30 {
  31         uint status = RNDIS_STATUS_SUCCESS;
  32         struct _adapter *Adapter = (struct _adapter *)
  33                                    (poid_par_priv->adapter_context);
  34 
  35         if (poid_par_priv->type_of_oid == SET_OID) {
  36                 if (poid_par_priv->information_buf_len >= sizeof(u8))
  37                         Adapter->registrypriv.wireless_mode =
  38                                         *(u8 *)poid_par_priv->information_buf;
  39                 else
  40                         status = RNDIS_STATUS_INVALID_LENGTH;
  41         } else if (poid_par_priv->type_of_oid == QUERY_OID) {
  42                 if (poid_par_priv->information_buf_len >= sizeof(u8)) {
  43                         *(u8 *)poid_par_priv->information_buf =
  44                                          Adapter->registrypriv.wireless_mode;
  45                         *poid_par_priv->bytes_rw =
  46                                         poid_par_priv->information_buf_len;
  47                 } else {
  48                         status = RNDIS_STATUS_INVALID_LENGTH;
  49                 }
  50         } else {
  51                 status = RNDIS_STATUS_NOT_ACCEPTED;
  52         }
  53         return status;
  54 }
  55 
  56 uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
  57 {
  58         struct _adapter *Adapter = (struct _adapter *)
  59                                    (poid_par_priv->adapter_context);
  60         struct bb_reg_param *pbbreg;
  61         u16 offset;
  62         u32 value;
  63 
  64         if (poid_par_priv->type_of_oid != SET_OID)
  65                 return RNDIS_STATUS_NOT_ACCEPTED;
  66         if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param))
  67                 return RNDIS_STATUS_INVALID_LENGTH;
  68         pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf);
  69         offset = (u16)(pbbreg->offset) & 0xFFF; /*0ffset :0x800~0xfff*/
  70         if (offset < BB_REG_BASE_ADDR)
  71                 offset |= BB_REG_BASE_ADDR;
  72         value = pbbreg->value;
  73         r8712_bb_reg_write(Adapter, offset, value);
  74         return RNDIS_STATUS_SUCCESS;
  75 }
  76 
  77 uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
  78 {
  79         struct _adapter *Adapter = (struct _adapter *)
  80                                    (poid_par_priv->adapter_context);
  81         struct bb_reg_param *pbbreg;
  82         u16 offset;
  83         u32 value;
  84 
  85         if (poid_par_priv->type_of_oid != QUERY_OID)
  86                 return RNDIS_STATUS_NOT_ACCEPTED;
  87         if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param))
  88                 return RNDIS_STATUS_INVALID_LENGTH;
  89         pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf);
  90         offset = (u16)(pbbreg->offset) & 0xFFF; /*0ffset :0x800~0xfff*/
  91         if (offset < BB_REG_BASE_ADDR)
  92                 offset |= BB_REG_BASE_ADDR;
  93         value = r8712_bb_reg_read(Adapter, offset);
  94         pbbreg->value = value;
  95         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
  96         return RNDIS_STATUS_SUCCESS;
  97 }
  98 
  99 uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
 100 {
 101         struct _adapter *Adapter = (struct _adapter *)
 102                                    (poid_par_priv->adapter_context);
 103         struct rf_reg_param *pbbreg;
 104         u8 path;
 105         u8 offset;
 106         u32 value;
 107 
 108         if (poid_par_priv->type_of_oid != SET_OID)
 109                 return RNDIS_STATUS_NOT_ACCEPTED;
 110         if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param))
 111                 return RNDIS_STATUS_INVALID_LENGTH;
 112         pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf);
 113         path = (u8)pbbreg->path;
 114         if (path > RF_PATH_B)
 115                 return RNDIS_STATUS_NOT_ACCEPTED;
 116         offset = (u8)pbbreg->offset;
 117         value = pbbreg->value;
 118         r8712_rf_reg_write(Adapter, path, offset, value);
 119         return RNDIS_STATUS_SUCCESS;
 120 }
 121 
 122 uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
 123 {
 124         struct _adapter *Adapter = (struct _adapter *)
 125                                    (poid_par_priv->adapter_context);
 126         struct rf_reg_param *pbbreg;
 127         u8 path;
 128         u8 offset;
 129         u32 value;
 130 
 131         if (poid_par_priv->type_of_oid != QUERY_OID)
 132                 return RNDIS_STATUS_NOT_ACCEPTED;
 133         if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param))
 134                 return RNDIS_STATUS_INVALID_LENGTH;
 135         pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf);
 136         path = (u8)pbbreg->path;
 137         if (path > RF_PATH_B) /* 1T2R  path_a /path_b */
 138                 return RNDIS_STATUS_NOT_ACCEPTED;
 139         offset = (u8)pbbreg->offset;
 140         value = r8712_rf_reg_read(Adapter, path, offset);
 141         pbbreg->value = value;
 142         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 143         return RNDIS_STATUS_SUCCESS;
 144 }
 145 
 146 /*This function initializes the DUT to the MP test mode*/
 147 static int mp_start_test(struct _adapter *padapter)
 148 {
 149         struct mp_priv *pmppriv = &padapter->mppriv;
 150         struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 151         struct wlan_network *tgt_network = &pmlmepriv->cur_network;
 152         struct wlan_bssid_ex bssid;
 153         struct sta_info *psta;
 154         unsigned long length;
 155         unsigned long irqL;
 156         int res = 0;
 157 
 158         /* 3 1. initialize a new struct wlan_bssid_ex */
 159         memcpy(bssid.MacAddress, pmppriv->network_macaddr, ETH_ALEN);
 160         bssid.Ssid.SsidLength = 16;
 161         memcpy(bssid.Ssid.Ssid, (unsigned char *)"mp_pseudo_adhoc",
 162                 bssid.Ssid.SsidLength);
 163         bssid.InfrastructureMode = Ndis802_11IBSS;
 164         bssid.NetworkTypeInUse = Ndis802_11DS;
 165         bssid.IELength = 0;
 166         length = r8712_get_wlan_bssid_ex_sz(&bssid);
 167         if (length % 4) {
 168                 /*round up to multiple of 4 bytes.*/
 169                 bssid.Length = ((length >> 2) + 1) << 2;
 170         } else {
 171                 bssid.Length = length;
 172         }
 173         spin_lock_irqsave(&pmlmepriv->lock, irqL);
 174         if (check_fwstate(pmlmepriv, WIFI_MP_STATE))
 175                 goto end_of_mp_start_test;
 176         /*init mp_start_test status*/
 177         pmppriv->prev_fw_state = get_fwstate(pmlmepriv);
 178         pmlmepriv->fw_state = WIFI_MP_STATE;
 179         if (pmppriv->mode == _LOOPBOOK_MODE_)
 180                 set_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE); /*append txdesc*/
 181         set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
 182         /* 3 2. create a new psta for mp driver */
 183         /* clear psta in the cur_network, if any */
 184         psta = r8712_get_stainfo(&padapter->stapriv,
 185                                  tgt_network->network.MacAddress);
 186         if (psta)
 187                 r8712_free_stainfo(padapter, psta);
 188         psta = r8712_alloc_stainfo(&padapter->stapriv, bssid.MacAddress);
 189         if (psta == NULL) {
 190                 res = -ENOMEM;
 191                 goto end_of_mp_start_test;
 192         }
 193         /* 3 3. join pseudo AdHoc */
 194         tgt_network->join_res = 1;
 195         tgt_network->aid = psta->aid = 1;
 196         memcpy(&tgt_network->network, &bssid, length);
 197         _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
 198         r8712_os_indicate_connect(padapter);
 199         /* Set to LINKED STATE for MP TRX Testing */
 200         set_fwstate(pmlmepriv, _FW_LINKED);
 201 end_of_mp_start_test:
 202         spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
 203         return res;
 204 }
 205 
 206 /*This function change the DUT from the MP test mode into normal mode */
 207 static int mp_stop_test(struct _adapter *padapter)
 208 {
 209         struct mp_priv *pmppriv = &padapter->mppriv;
 210         struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 211         struct wlan_network *tgt_network = &pmlmepriv->cur_network;
 212         struct sta_info *psta;
 213         unsigned long irqL;
 214 
 215         spin_lock_irqsave(&pmlmepriv->lock, irqL);
 216         if (!check_fwstate(pmlmepriv, WIFI_MP_STATE))
 217                 goto end_of_mp_stop_test;
 218         /* 3 1. disconnect pseudo AdHoc */
 219         r8712_os_indicate_disconnect(padapter);
 220         /* 3 2. clear psta used in mp test mode. */
 221         psta = r8712_get_stainfo(&padapter->stapriv,
 222                                  tgt_network->network.MacAddress);
 223         if (psta)
 224                 r8712_free_stainfo(padapter, psta);
 225         /* 3 3. return to normal state (default:station mode) */
 226         pmlmepriv->fw_state = pmppriv->prev_fw_state; /* WIFI_STATION_STATE;*/
 227         /*flush the cur_network*/
 228         memset(tgt_network, 0, sizeof(struct wlan_network));
 229 end_of_mp_stop_test:
 230         spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
 231         return _SUCCESS;
 232 }
 233 
 234 uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv
 235                                          *poid_par_priv)
 236 {
 237         struct _adapter *Adapter = (struct _adapter *)
 238                                    (poid_par_priv->adapter_context);
 239         u32 ratevalue;
 240 
 241         if (poid_par_priv->type_of_oid != SET_OID)
 242                 return RNDIS_STATUS_NOT_ACCEPTED;
 243         if (poid_par_priv->information_buf_len != sizeof(u32))
 244                 return RNDIS_STATUS_INVALID_LENGTH;
 245         ratevalue = *((u32 *)poid_par_priv->information_buf);
 246         if (ratevalue >= MPT_RATE_LAST)
 247                 return RNDIS_STATUS_INVALID_DATA;
 248         Adapter->mppriv.curr_rateidx = ratevalue;
 249         r8712_SetDataRate(Adapter);
 250         return RNDIS_STATUS_SUCCESS;
 251 }
 252 
 253 uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv)
 254 {
 255         struct _adapter *Adapter = (struct _adapter *)
 256                                    (poid_par_priv->adapter_context);
 257         uint status = RNDIS_STATUS_SUCCESS;
 258         u32 mode;
 259         u8 val8;
 260 
 261         if (poid_par_priv->type_of_oid != SET_OID)
 262                 return  RNDIS_STATUS_NOT_ACCEPTED;
 263         mode = *((u32 *)poid_par_priv->information_buf);
 264         Adapter->mppriv.mode = mode;/* 1 for loopback*/
 265         if (mp_start_test(Adapter))
 266                 status = RNDIS_STATUS_NOT_ACCEPTED;
 267         r8712_write8(Adapter, MSR, 1); /* Link in ad hoc network, 0x1025004C */
 268         r8712_write8(Adapter, RCR, 0); /* RCR : disable all pkt, 0x10250048 */
 269         /* RCR disable Check BSSID, 0x1025004a */
 270         r8712_write8(Adapter, RCR + 2, 0x57);
 271         /* disable RX filter map , mgt frames will put in RX FIFO 0 */
 272         r8712_write16(Adapter, RXFLTMAP0, 0x0);
 273         val8 = r8712_read8(Adapter, EE_9346CR);
 274         if (!(val8 & _9356SEL)) { /*boot from EFUSE*/
 275                 r8712_efuse_reg_init(Adapter);
 276                 r8712_efuse_change_max_size(Adapter);
 277                 r8712_efuse_reg_uninit(Adapter);
 278         }
 279         return status;
 280 }
 281 
 282 uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv)
 283 {
 284         struct _adapter *Adapter = (struct _adapter *)
 285                                    (poid_par_priv->adapter_context);
 286         uint status = RNDIS_STATUS_SUCCESS;
 287 
 288         if (poid_par_priv->type_of_oid != SET_OID)
 289                 return RNDIS_STATUS_NOT_ACCEPTED;
 290         if (mp_stop_test(Adapter) == _FAIL)
 291                 status = RNDIS_STATUS_NOT_ACCEPTED;
 292         return status;
 293 }
 294 
 295 uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv
 296                                                    *poid_par_priv)
 297 {
 298         struct _adapter *Adapter = (struct _adapter *)
 299                                    (poid_par_priv->adapter_context);
 300         u32             Channel;
 301 
 302         if (poid_par_priv->type_of_oid != SET_OID)
 303                 return RNDIS_STATUS_NOT_ACCEPTED;
 304         if (poid_par_priv->information_buf_len != sizeof(u32))
 305                 return RNDIS_STATUS_INVALID_LENGTH;
 306         Channel = *((u32 *)poid_par_priv->information_buf);
 307         if (Channel > 14)
 308                 return RNDIS_STATUS_NOT_ACCEPTED;
 309         Adapter->mppriv.curr_ch = Channel;
 310         r8712_SetChannel(Adapter);
 311         return RNDIS_STATUS_SUCCESS;
 312 }
 313 
 314 uint oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv)
 315 {
 316         struct _adapter *Adapter = (struct _adapter *)
 317                                    (poid_par_priv->adapter_context);
 318         u32 antenna;
 319 
 320         if (poid_par_priv->type_of_oid != SET_OID)
 321                 return RNDIS_STATUS_NOT_ACCEPTED;
 322         if (poid_par_priv->information_buf_len != sizeof(u32))
 323                 return RNDIS_STATUS_INVALID_LENGTH;
 324         antenna = *((u32 *)poid_par_priv->information_buf);
 325         Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16);
 326         Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF);
 327         r8712_SwitchAntenna(Adapter);
 328         return RNDIS_STATUS_SUCCESS;
 329 }
 330 
 331 uint oid_rt_pro_set_tx_power_control_hdl(
 332                                         struct oid_par_priv *poid_par_priv)
 333 {
 334         struct _adapter *Adapter = (struct _adapter *)
 335                                    (poid_par_priv->adapter_context);
 336         u32 tx_pwr_idx;
 337 
 338         if (poid_par_priv->type_of_oid != SET_OID)
 339                 return RNDIS_STATUS_NOT_ACCEPTED;
 340         if (poid_par_priv->information_buf_len != sizeof(u32))
 341                 return RNDIS_STATUS_INVALID_LENGTH;
 342         tx_pwr_idx = *((u32 *)poid_par_priv->information_buf);
 343         if (tx_pwr_idx > MAX_TX_PWR_INDEX_N_MODE)
 344                 return RNDIS_STATUS_NOT_ACCEPTED;
 345         Adapter->mppriv.curr_txpoweridx = (u8)tx_pwr_idx;
 346         r8712_SetTxPower(Adapter);
 347         return RNDIS_STATUS_SUCCESS;
 348 }
 349 
 350 uint oid_rt_pro_query_tx_packet_sent_hdl(
 351                                         struct oid_par_priv *poid_par_priv)
 352 {
 353         uint status = RNDIS_STATUS_SUCCESS;
 354         struct _adapter *Adapter = (struct _adapter *)
 355                                    (poid_par_priv->adapter_context);
 356 
 357         if (poid_par_priv->type_of_oid != QUERY_OID) {
 358                 status = RNDIS_STATUS_NOT_ACCEPTED;
 359                 return status;
 360         }
 361         if (poid_par_priv->information_buf_len == sizeof(u32)) {
 362                 *(u32 *)poid_par_priv->information_buf =
 363                                         Adapter->mppriv.tx_pktcount;
 364                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 365         } else {
 366                 status = RNDIS_STATUS_INVALID_LENGTH;
 367         }
 368         return status;
 369 }
 370 
 371 uint oid_rt_pro_query_rx_packet_received_hdl(
 372                                         struct oid_par_priv *poid_par_priv)
 373 {
 374         uint status = RNDIS_STATUS_SUCCESS;
 375         struct _adapter *Adapter = (struct _adapter *)
 376                                    (poid_par_priv->adapter_context);
 377 
 378         if (poid_par_priv->type_of_oid != QUERY_OID) {
 379                 status = RNDIS_STATUS_NOT_ACCEPTED;
 380                 return status;
 381         }
 382         if (poid_par_priv->information_buf_len == sizeof(u32)) {
 383                 *(u32 *)poid_par_priv->information_buf =
 384                                         Adapter->mppriv.rx_pktcount;
 385                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 386         } else {
 387                 status = RNDIS_STATUS_INVALID_LENGTH;
 388         }
 389         return status;
 390 }
 391 
 392 uint oid_rt_pro_query_rx_packet_crc32_error_hdl(
 393                                         struct oid_par_priv *poid_par_priv)
 394 {
 395         uint status = RNDIS_STATUS_SUCCESS;
 396         struct _adapter *Adapter = (struct _adapter *)
 397                                    (poid_par_priv->adapter_context);
 398 
 399         if (poid_par_priv->type_of_oid != QUERY_OID) {
 400                 status = RNDIS_STATUS_NOT_ACCEPTED;
 401                 return status;
 402         }
 403         if (poid_par_priv->information_buf_len == sizeof(u32)) {
 404                 *(u32 *)poid_par_priv->information_buf =
 405                                         Adapter->mppriv.rx_crcerrpktcount;
 406                 *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 407         } else {
 408                 status = RNDIS_STATUS_INVALID_LENGTH;
 409         }
 410         return status;
 411 }
 412 
 413 uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv
 414                                                 *poid_par_priv)
 415 {
 416         struct _adapter *Adapter = (struct _adapter *)
 417                                    (poid_par_priv->adapter_context);
 418 
 419         if (poid_par_priv->type_of_oid != SET_OID)
 420                 return RNDIS_STATUS_NOT_ACCEPTED;
 421         Adapter->mppriv.tx_pktcount = 0;
 422         return RNDIS_STATUS_SUCCESS;
 423 }
 424 
 425 uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv
 426                                                     *poid_par_priv)
 427 {
 428         uint status = RNDIS_STATUS_SUCCESS;
 429         struct _adapter *Adapter = (struct _adapter *)
 430                                    (poid_par_priv->adapter_context);
 431 
 432         if (poid_par_priv->type_of_oid != SET_OID)
 433                 return RNDIS_STATUS_NOT_ACCEPTED;
 434         if (poid_par_priv->information_buf_len == sizeof(u32)) {
 435                 Adapter->mppriv.rx_pktcount = 0;
 436                 Adapter->mppriv.rx_crcerrpktcount = 0;
 437         } else {
 438                 status = RNDIS_STATUS_INVALID_LENGTH;
 439         }
 440         return status;
 441 }
 442 
 443 uint oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv
 444                                                  *poid_par_priv)
 445 {
 446         struct _adapter *Adapter = (struct _adapter *)
 447                                    (poid_par_priv->adapter_context);
 448 
 449         if (poid_par_priv->type_of_oid != SET_OID)
 450                 return RNDIS_STATUS_NOT_ACCEPTED;
 451         r8712_ResetPhyRxPktCount(Adapter);
 452         return RNDIS_STATUS_SUCCESS;
 453 }
 454 
 455 uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv
 456                                                   *poid_par_priv)
 457 {
 458         struct _adapter *Adapter = (struct _adapter *)
 459                                    (poid_par_priv->adapter_context);
 460 
 461         if (poid_par_priv->type_of_oid != QUERY_OID)
 462                 return RNDIS_STATUS_NOT_ACCEPTED;
 463         if (poid_par_priv->information_buf_len != sizeof(u32))
 464                 return RNDIS_STATUS_INVALID_LENGTH;
 465         *(u32 *)poid_par_priv->information_buf =
 466                                          r8712_GetPhyRxPktReceived(Adapter);
 467         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 468         return RNDIS_STATUS_SUCCESS;
 469 }
 470 
 471 uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv
 472                                                      *poid_par_priv)
 473 {
 474         struct _adapter *Adapter = (struct _adapter *)
 475                                    (poid_par_priv->adapter_context);
 476 
 477         if (poid_par_priv->type_of_oid != QUERY_OID)
 478                 return RNDIS_STATUS_NOT_ACCEPTED;
 479         if (poid_par_priv->information_buf_len != sizeof(u32))
 480                 return RNDIS_STATUS_INVALID_LENGTH;
 481         *(u32 *)poid_par_priv->information_buf =
 482                                          r8712_GetPhyRxPktCRC32Error(Adapter);
 483         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 484         return RNDIS_STATUS_SUCCESS;
 485 }
 486 
 487 uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv
 488                                           *poid_par_priv)
 489 {
 490         struct _adapter *Adapter = (struct _adapter *)
 491                                    (poid_par_priv->adapter_context);
 492 
 493         if (poid_par_priv->type_of_oid != SET_OID)
 494                 return RNDIS_STATUS_NOT_ACCEPTED;
 495 
 496         Adapter->mppriv.curr_modem = *((u8 *)poid_par_priv->information_buf);
 497         return RNDIS_STATUS_SUCCESS;
 498 }
 499 
 500 uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv
 501                                              *poid_par_priv)
 502 {
 503         struct _adapter *Adapter = (struct _adapter *)
 504                                    (poid_par_priv->adapter_context);
 505         u32             bStartTest;
 506 
 507         if (poid_par_priv->type_of_oid != SET_OID)
 508                 return RNDIS_STATUS_NOT_ACCEPTED;
 509         bStartTest = *((u32 *)poid_par_priv->information_buf);
 510         r8712_SetContinuousTx(Adapter, (u8)bStartTest);
 511         return RNDIS_STATUS_SUCCESS;
 512 }
 513 
 514 uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv
 515                                                  *poid_par_priv)
 516 {
 517         struct _adapter *Adapter = (struct _adapter *)
 518                                    (poid_par_priv->adapter_context);
 519         u32             bStartTest;
 520 
 521         if (poid_par_priv->type_of_oid != SET_OID)
 522                 return RNDIS_STATUS_NOT_ACCEPTED;
 523         bStartTest = *((u32 *)poid_par_priv->information_buf);
 524         r8712_SetSingleCarrierTx(Adapter, (u8)bStartTest);
 525         return RNDIS_STATUS_SUCCESS;
 526 }
 527 
 528 uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv
 529                                                       *poid_par_priv)
 530 {
 531         struct _adapter *Adapter = (struct _adapter *)
 532                                    (poid_par_priv->adapter_context);
 533         u32             bStartTest;
 534 
 535         if (poid_par_priv->type_of_oid != SET_OID)
 536                 return RNDIS_STATUS_NOT_ACCEPTED;
 537         bStartTest = *((u32 *)poid_par_priv->information_buf);
 538         r8712_SetCarrierSuppressionTx(Adapter, (u8)bStartTest);
 539         return RNDIS_STATUS_SUCCESS;
 540 }
 541 
 542 uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv
 543                                               *poid_par_priv)
 544 {
 545         struct _adapter *Adapter = (struct _adapter *)
 546                                    (poid_par_priv->adapter_context);
 547         u32             bStartTest;
 548 
 549         if (poid_par_priv->type_of_oid != SET_OID)
 550                 return RNDIS_STATUS_NOT_ACCEPTED;
 551         bStartTest = *((u32 *)poid_par_priv->information_buf);
 552         r8712_SetSingleToneTx(Adapter, (u8)bStartTest);
 553         return RNDIS_STATUS_SUCCESS;
 554 }
 555 
 556 uint oid_rt_pro_read_register_hdl(struct oid_par_priv
 557                                          *poid_par_priv)
 558 {
 559         struct _adapter *Adapter = (struct _adapter *)
 560                                    (poid_par_priv->adapter_context);
 561         uint status = RNDIS_STATUS_SUCCESS;
 562         struct mp_rw_reg *RegRWStruct;
 563         u16             offset;
 564 
 565         if (poid_par_priv->type_of_oid != QUERY_OID)
 566                 return RNDIS_STATUS_NOT_ACCEPTED;
 567         RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf;
 568         if ((RegRWStruct->offset >= 0x10250800) &&
 569             (RegRWStruct->offset <= 0x10250FFF)) {
 570                 /*baseband register*/
 571                 /*0ffset :0x800~0xfff*/
 572                 offset = (u16)(RegRWStruct->offset) & 0xFFF;
 573                 RegRWStruct->value = r8712_bb_reg_read(Adapter, offset);
 574         } else {
 575                 switch (RegRWStruct->width) {
 576                 case 1:
 577                         RegRWStruct->value = r8712_read8(Adapter,
 578                                                    RegRWStruct->offset);
 579                         break;
 580                 case 2:
 581                         RegRWStruct->value = r8712_read16(Adapter,
 582                                                     RegRWStruct->offset);
 583                         break;
 584                 case 4:
 585                         RegRWStruct->value = r8712_read32(Adapter,
 586                                                     RegRWStruct->offset);
 587                         break;
 588                 default:
 589                         status = RNDIS_STATUS_NOT_ACCEPTED;
 590                         break;
 591                 }
 592         }
 593         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 594         return status;
 595 }
 596 
 597 uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv)
 598 {
 599         struct _adapter *Adapter = (struct _adapter *)
 600                                    (poid_par_priv->adapter_context);
 601         uint status = RNDIS_STATUS_SUCCESS;
 602         struct mp_rw_reg *RegRWStruct;
 603         u16             offset;
 604         u32             value;
 605         u32 oldValue = 0;
 606 
 607         if (poid_par_priv->type_of_oid != SET_OID)
 608                 return RNDIS_STATUS_NOT_ACCEPTED;
 609         RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf;
 610         if ((RegRWStruct->offset >= 0x10250800) &&
 611             (RegRWStruct->offset <= 0x10250FFF)) {
 612                 /*baseband register*/
 613                 offset = (u16)(RegRWStruct->offset) & 0xFFF;
 614                 value = RegRWStruct->value;
 615                 switch (RegRWStruct->width) {
 616                 case 1:
 617                         oldValue = r8712_bb_reg_read(Adapter, offset);
 618                         oldValue &= 0xFFFFFF00;
 619                         value &= 0x000000FF;
 620                         value |= oldValue;
 621                         break;
 622                 case 2:
 623                         oldValue = r8712_bb_reg_read(Adapter, offset);
 624                         oldValue &= 0xFFFF0000;
 625                         value &= 0x0000FFFF;
 626                         value |= oldValue;
 627                         break;
 628                 }
 629                 r8712_bb_reg_write(Adapter, offset, value);
 630         } else {
 631                 switch (RegRWStruct->width) {
 632                 case 1:
 633                         r8712_write8(Adapter, RegRWStruct->offset,
 634                                (unsigned char)RegRWStruct->value);
 635                         break;
 636                 case 2:
 637                         r8712_write16(Adapter, RegRWStruct->offset,
 638                                 (unsigned short)RegRWStruct->value);
 639                         break;
 640                 case 4:
 641                         r8712_write32(Adapter, RegRWStruct->offset,
 642                                 (unsigned int)RegRWStruct->value);
 643                         break;
 644                 default:
 645                         status = RNDIS_STATUS_NOT_ACCEPTED;
 646                         break;
 647                 }
 648         }
 649         return status;
 650 }
 651 
 652 uint oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv)
 653 {
 654         struct _adapter *Adapter = (struct _adapter *)
 655                                    (poid_par_priv->adapter_context);
 656 
 657         if (poid_par_priv->type_of_oid != QUERY_OID)
 658                 return RNDIS_STATUS_NOT_ACCEPTED;
 659 
 660         if (Adapter->mppriv.act_in_progress)
 661                 return RNDIS_STATUS_NOT_ACCEPTED;
 662 
 663         if (poid_par_priv->information_buf_len < sizeof(u8))
 664                 return RNDIS_STATUS_INVALID_LENGTH;
 665         /*init workparam*/
 666         Adapter->mppriv.act_in_progress = true;
 667         Adapter->mppriv.workparam.bcompleted = false;
 668         Adapter->mppriv.workparam.act_type = MPT_GET_THERMAL_METER;
 669         Adapter->mppriv.workparam.io_offset = 0;
 670         Adapter->mppriv.workparam.io_value = 0xFFFFFFFF;
 671         r8712_GetThermalMeter(Adapter, &Adapter->mppriv.workparam.io_value);
 672         Adapter->mppriv.workparam.bcompleted = true;
 673         Adapter->mppriv.act_in_progress = false;
 674         *(u32 *)poid_par_priv->information_buf =
 675                                  Adapter->mppriv.workparam.io_value;
 676         *poid_par_priv->bytes_rw = sizeof(u32);
 677         return RNDIS_STATUS_SUCCESS;
 678 }
 679 
 680 uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv)
 681 {
 682         struct _adapter *Adapter = (struct _adapter *)
 683                                    (poid_par_priv->adapter_context);
 684 
 685         uint status = RNDIS_STATUS_SUCCESS;
 686 
 687         struct EFUSE_ACCESS_STRUCT *pefuse;
 688         u8 *data;
 689         u16 addr = 0, cnts = 0;
 690 
 691         if (poid_par_priv->type_of_oid != QUERY_OID)
 692                 return RNDIS_STATUS_NOT_ACCEPTED;
 693         if (poid_par_priv->information_buf_len <
 694             sizeof(struct EFUSE_ACCESS_STRUCT))
 695                 return RNDIS_STATUS_INVALID_LENGTH;
 696         pefuse = (struct EFUSE_ACCESS_STRUCT *)poid_par_priv->information_buf;
 697         addr = pefuse->start_addr;
 698         cnts = pefuse->cnts;
 699         data = pefuse->data;
 700         memset(data, 0xFF, cnts);
 701         if ((addr > 511) || (cnts < 1) || (cnts > 512) || (addr + cnts) >
 702              EFUSE_MAX_SIZE)
 703                 return RNDIS_STATUS_NOT_ACCEPTED;
 704         if (!r8712_efuse_access(Adapter, true, addr, cnts, data))
 705                 status = RNDIS_STATUS_FAILURE;
 706         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 707         return status;
 708 }
 709 /*------------------------------------------------------------------------*/
 710 uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv)
 711 {
 712         struct _adapter *Adapter = (struct _adapter *)
 713                                    (poid_par_priv->adapter_context);
 714 
 715         uint status = RNDIS_STATUS_SUCCESS;
 716 
 717         struct EFUSE_ACCESS_STRUCT *pefuse;
 718         u8 *data;
 719         u16 addr = 0, cnts = 0;
 720 
 721         if (poid_par_priv->type_of_oid != SET_OID)
 722                 return RNDIS_STATUS_NOT_ACCEPTED;
 723 
 724         pefuse = (struct EFUSE_ACCESS_STRUCT *)poid_par_priv->information_buf;
 725         addr = pefuse->start_addr;
 726         cnts = pefuse->cnts;
 727         data = pefuse->data;
 728 
 729         if ((addr > 511) || (cnts < 1) || (cnts > 512) ||
 730             (addr + cnts) > r8712_efuse_get_max_size(Adapter))
 731                 return RNDIS_STATUS_NOT_ACCEPTED;
 732         if (!r8712_efuse_access(Adapter, false, addr, cnts, data))
 733                 status = RNDIS_STATUS_FAILURE;
 734         return status;
 735 }
 736 /*----------------------------------------------------------------------*/
 737 
 738 uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv
 739                                               *poid_par_priv)
 740 {
 741         struct _adapter *Adapter = (struct _adapter *)
 742                                    (poid_par_priv->adapter_context);
 743 
 744         if (poid_par_priv->type_of_oid != QUERY_OID)
 745                 return RNDIS_STATUS_NOT_ACCEPTED;
 746         if (poid_par_priv->information_buf_len < sizeof(int))
 747                 return RNDIS_STATUS_INVALID_LENGTH;
 748         r8712_efuse_reg_init(Adapter);
 749         *(int *)poid_par_priv->information_buf =
 750                                  r8712_efuse_get_current_size(Adapter);
 751         r8712_efuse_reg_uninit(Adapter);
 752         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 753         return RNDIS_STATUS_SUCCESS;
 754 }
 755 
 756 uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv)
 757 {
 758         struct _adapter *Adapter = (struct _adapter *)
 759                                    (poid_par_priv->adapter_context);
 760 
 761         if (poid_par_priv->type_of_oid != QUERY_OID)
 762                 return RNDIS_STATUS_NOT_ACCEPTED;
 763         if (poid_par_priv->information_buf_len < sizeof(u32))
 764                 return RNDIS_STATUS_INVALID_LENGTH;
 765         *(int *)poid_par_priv->information_buf =
 766                                          r8712_efuse_get_max_size(Adapter);
 767         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 768         return RNDIS_STATUS_SUCCESS;
 769 }
 770 
 771 uint oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv)
 772 {
 773         uint status = RNDIS_STATUS_SUCCESS;
 774 
 775         if (poid_par_priv->type_of_oid == QUERY_OID)
 776                 status = oid_rt_pro_read_efuse_hdl(poid_par_priv);
 777         else
 778                 status = oid_rt_pro_write_efuse_hdl(poid_par_priv);
 779         return status;
 780 }
 781 
 782 uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv)
 783 {
 784         struct _adapter *Adapter = (struct _adapter *)
 785                                    (poid_par_priv->adapter_context);
 786         uint status = RNDIS_STATUS_SUCCESS;
 787         u8              *data;
 788 
 789         *poid_par_priv->bytes_rw = 0;
 790         if (poid_par_priv->information_buf_len < EFUSE_MAP_MAX_SIZE)
 791                 return RNDIS_STATUS_INVALID_LENGTH;
 792         data = (u8 *)poid_par_priv->information_buf;
 793         if (poid_par_priv->type_of_oid == QUERY_OID) {
 794                 if (r8712_efuse_map_read(Adapter, 0, EFUSE_MAP_MAX_SIZE, data))
 795                         *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE;
 796                 else
 797                         status = RNDIS_STATUS_FAILURE;
 798         } else {
 799                 /* SET_OID */
 800                 if (r8712_efuse_reg_init(Adapter)) {
 801                         if (r8712_efuse_map_write(Adapter, 0,
 802                             EFUSE_MAP_MAX_SIZE, data))
 803                                 *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE;
 804                         else
 805                                 status = RNDIS_STATUS_FAILURE;
 806                         r8712_efuse_reg_uninit(Adapter);
 807                 } else {
 808                         status = RNDIS_STATUS_FAILURE;
 809                 }
 810         }
 811         return status;
 812 }
 813 
 814 uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv)
 815 {
 816         struct _adapter *Adapter = (struct _adapter *)
 817                                    (poid_par_priv->adapter_context);
 818         u32             bandwidth;
 819 
 820         if (poid_par_priv->type_of_oid != SET_OID)
 821                 return RNDIS_STATUS_NOT_ACCEPTED;
 822         if (poid_par_priv->information_buf_len < sizeof(u32))
 823                 return RNDIS_STATUS_INVALID_LENGTH;
 824         bandwidth = *((u32 *)poid_par_priv->information_buf);/*4*/
 825         if (bandwidth != HT_CHANNEL_WIDTH_20)
 826                 bandwidth = HT_CHANNEL_WIDTH_40;
 827         Adapter->mppriv.curr_bandwidth = (u8)bandwidth;
 828         r8712_SwitchBandwidth(Adapter);
 829         return RNDIS_STATUS_SUCCESS;
 830 }
 831 
 832 uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv
 833                                            *poid_par_priv)
 834 {
 835         struct _adapter *Adapter = (struct _adapter *)
 836                                    (poid_par_priv->adapter_context);
 837         u8              rx_pkt_type;
 838         u32             rcr_val32;
 839 
 840         if (poid_par_priv->type_of_oid != SET_OID)
 841                 return RNDIS_STATUS_NOT_ACCEPTED;
 842         if (poid_par_priv->information_buf_len < sizeof(u8))
 843                 return RNDIS_STATUS_INVALID_LENGTH;
 844         rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/*4*/
 845         rcr_val32 = r8712_read32(Adapter, RCR);/*RCR = 0x10250048*/
 846         rcr_val32 &= ~(RCR_CBSSID | RCR_AB | RCR_AM | RCR_APM | RCR_AAP);
 847         switch (rx_pkt_type) {
 848         case RX_PKT_BROADCAST:
 849                 rcr_val32 |= (RCR_AB | RCR_AM | RCR_APM | RCR_AAP | RCR_ACRC32);
 850                 break;
 851         case RX_PKT_DEST_ADDR:
 852                 rcr_val32 |= (RCR_AB | RCR_AM | RCR_APM | RCR_AAP | RCR_ACRC32);
 853                 break;
 854         case RX_PKT_PHY_MATCH:
 855                 rcr_val32 |= (RCR_APM | RCR_ACRC32);
 856                 break;
 857         default:
 858                 rcr_val32 &= ~(RCR_AAP |
 859                                RCR_APM |
 860                                RCR_AM |
 861                                RCR_AB |
 862                                RCR_ACRC32);
 863                 break;
 864         }
 865         if (rx_pkt_type == RX_PKT_DEST_ADDR)
 866                 Adapter->mppriv.check_mp_pkt = 1;
 867         else
 868                 Adapter->mppriv.check_mp_pkt = 0;
 869         r8712_write32(Adapter, RCR, rcr_val32);
 870         return RNDIS_STATUS_SUCCESS;
 871 }
 872 
 873 /*--------------------------------------------------------------------------*/
 874 /*Linux*/
 875 unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv)
 876 {
 877         return _SUCCESS;
 878 }
 879 /*-------------------------------------------------------------------------*/
 880 uint oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv)
 881 {
 882         if (poid_par_priv->type_of_oid != SET_OID)
 883                 return RNDIS_STATUS_NOT_ACCEPTED;
 884         /*CALL  the power_down function*/
 885         return RNDIS_STATUS_SUCCESS;
 886 }
 887 
 888 /*-------------------------------------------------------------------------- */
 889 uint oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv)
 890 {
 891         struct _adapter *Adapter = (struct _adapter *)
 892                                    (poid_par_priv->adapter_context);
 893 
 894         if (poid_par_priv->type_of_oid != QUERY_OID)
 895                 return RNDIS_STATUS_NOT_ACCEPTED;
 896         if (poid_par_priv->information_buf_len < sizeof(u32))
 897                 return RNDIS_STATUS_INVALID_LENGTH;
 898         *(int *)poid_par_priv->information_buf =
 899                  Adapter->registrypriv.low_power ? POWER_LOW : POWER_NORMAL;
 900         *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
 901         return RNDIS_STATUS_SUCCESS;
 902 }

/* [<][>][^][v][top][bottom][index][help] */