1 /* 2 * Copyright 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifdef CONFIG_LGE_WLAN_QCOM_PATCH 18 19 #include <stdio.h> 20 #include <stdlib.h> 21 #include <string.h> 22 23 #include "wfc_util_log.h" 24 #include "wfc_util_fctrl.h" 25 #include "wfc_util_common.h" 26 27 #include "private/android_filesystem_config.h" 28 29 #define WFC_UTIL_FEAUTRE_COPY_NV_BIN 30 31 #ifdef WLAN_CHIP_VERSION_WCNSS 32 #ifndef WFC_UTIL_CFG_FILE_NAME 33 #define WFC_UTIL_CFG_FILE_NAME "/data/misc/wifi/WCNSS_qcom_cfg.ini" 34 #endif 35 #ifndef WFC_UTIL_CFG_TEMPFILE_NAME 36 #define WFC_UTIL_CFG_TEMPFILE_NAME "/system/etc/wifi/WCNSS_qcom_cfg.ini" 37 #endif 38 #else /* WLAN_CHIP_VERSION_WCN1314 */ 39 #ifndef WFC_UTIL_CFG_FILE_NAME 40 #define WFC_UTIL_CFG_FILE_NAME "/data/misc/wifi/WCN1314_qcom_cfg.ini" 41 #endif 42 #ifndef WFC_UTIL_CFG_TEMPFILE_NAME 43 #define WFC_UTIL_CFG_TEMPFILE_NAME "/system/etc/wifi/WCN1314_qcom_cfg.ini" 44 #endif 45 #endif /* WLAN_CHIP_VERSION_XXXX */ 46 47 #ifdef WFC_UTIL_FEAUTRE_COPY_NV_BIN 48 #ifdef WLAN_CHIP_VERSION_WCNSS 49 #ifndef WFC_UTIL_NV_BIN_TEMPFILE_NAME 50 #define WFC_UTIL_NV_BIN_TEMPFILE_NAME "/system/etc/wifi/WCNSS_qcom_wlan_nv.bin" 51 #endif 52 #ifndef WFC_UTIL_NV_BIN_FILE_NAME 53 #define WFC_UTIL_NV_BIN_FILE_NAME "/data/misc/wifi/WCNSS_qcom_wlan_nv.bin" 54 #endif 55 #else /* WLAN_CHIP_VERSION_WCN1314 */ 56 #ifndef WFC_UTIL_NV_BIN_TEMPFILE_NAME 57 #define WFC_UTIL_NV_BIN_TEMPFILE_NAME "/persist/WCN1314_qcom_wlan_nv.bin" 58 #endif 59 #ifndef WFC_UTIL_NV_BIN_FILE_NAME 60 #define WFC_UTIL_NV_BIN_FILE_NAME "/data/misc/wifi/WCN1314_qcom_wlan_nv.bin" 61 #endif 62 #endif /* WLAN_CHIP_VERSION_XXXX */ 63 #else /* WFC_UTIL_FEAUTRE_COPY_NV_BIN */ 64 #ifndef WFC_UTIL_NV_BIN_FILE_NAME 65 #ifdef WLAN_CHIP_VERSION_WCNSS 66 #define WFC_UTIL_NV_BIN_FILE_NAME "/persist/WCNSS_qcom_wlan_nv.bin" 67 #else /* WLAN_CHIP_VERSION_WCN1314 */ 68 #define WFC_UTIL_NV_BIN_FILE_NAME "/persist/WCN1314_qcom_wlan_nv.bin" 69 #endif /* WLAN_CHIP_VERSION_XXXX */ 70 #endif 71 #endif /* WFC_UTIL_FEAUTRE_COPY_NV_BIN */ 72 73 #define WFC_UTIL_CFG_TAG_END_OF_CFG "END" 74 /* 75 * Station Mode MAC Address 76 */ 77 #ifdef WLAN_CHIP_VERSION_WCNSS 78 #define WFC_UTIL_CFG_TAG_MAC_ADDRESS "Intf0MacAddress=" 79 #else /* WLAN_CHIP_VERSION_WCN1314 */ 80 #define WFC_UTIL_CFG_TAG_MAC_ADDRESS "NetworkAddress=" 81 #endif /* WLAN_CHIP_VERSION_XXXX */ 82 /* 83 * AP Mode MAC Address 84 */ 85 #define WFC_UTIL_CFG_TAG_AP_MAC_ADDRESS "gAPMacAddr=" 86 87 /* 88 * Idle Mode Power Save enable/disable for OTA test 89 */ 90 #define WFC_UTIL_CFG_TAG_IDLE_MODE_POWER_SAVE "gEnableImps=" 91 92 /* 93 * Beacon Mode Power Save enable/disable for OTA test 94 */ 95 #define WFC_UTIL_CFG_TAG_POWER_SAVE "gEnableBmps=" 96 97 /* 98 * L2 roaming on/off for OTA test 99 */ 100 #define WFC_UTIL_CFG_TAG_L2Roaming "gEnableHandoff=" 101 102 /* 103 * Heartbeat24 changing for OtA test 104 */ 105 #define WFC_UTIL_CFG_TAG_HEARTBEAT24 "gHeartbeat24=" 106 107 /* 108 * TAG for end of line 109 */ 110 #define WFC_UTIL_CFG_TAG_END_OF_LINE "\n" 111 112 #define WFC_UTIL_CFG_LENGHT_MAC (6) 113 #define WFC_UTIL_CFG_LENGHT_MAC_STRING (WFC_UTIL_CFG_LENGHT_MAC*2) 114 115 /* 116 * persist/WCNSS_qcom_wlan_nv.bin 117 * 118 * NV validity bitmap (4 bytes) 119 * { 120 * Bit 0 - Regulatory domain tables 121 * Bit 1 - Fields(including product ID, product bands, number of Tx/Rx chains, MAC address, manufacturing board number) 122 * Bit 2 - Optimal power per rate table 123 * Bit 3 - Default regulatory domain and country code 124 * Bit 4:31 - Reserved; always 0 125 * } 126 * 127 * typedef PACKED_PRE struct PACKED_POST 128 * { 129 * //always ensure fields are aligned to 32-bit boundaries 130 * tANI_U16 productId; 131 * tANI_U8 productBands; //0: 0.4 GHz, 1: 2.4+5.0 GHz, 2: 5.0 GHz 132 * tANI_U8 wlanNvRevId; //0: WCN1312, 1: WCN1314, 2: PRIMA 133 * 134 * tANI_U8 numOfTxChains; 135 * tANI_U8 numOfRxChains; 136 * tANI_U8 macAddr[NV_FIELD_MAC_ADDR_SIZE]; 137 * tANI_U8 mfgSN[NV_FIELD_MFG_SN_SIZE]; 138 * } sNvFields; 139 */ 140 #define WFC_UTIL_NV_BIN_HEADER_LENGTH (4) 141 #define WFC_UTIL_NV_BIN_POS_PRODUCT_ID (WFC_UTIL_NV_BIN_HEADER_LENGTH + 0) 142 #define WFC_UTIL_NV_BIN_POS_MAC_ADDR (WFC_UTIL_NV_BIN_HEADER_LENGTH + 6) 143 144 #ifdef WLAN_CHIP_VERSION_WCNSS 145 /* refer to prima/CORE/WDA/src/wlan_nv.c */ 146 static unsigned char nvFilelds_default[6] = {0, 0, /* productId */ 147 1, /* productBands */ 148 2, /* wlanNvRevId */ 149 1, /* numOfTxChains */ 150 2}; /* numOfRxChains */ 151 #else /* WLAN_CHIP_VERSION_WCN1314 */ 152 static unsigned char nvFilelds_default[6] = {1, 0, /* productId */ 153 1, /* productBands */ 154 1, /* wlanNvRevId */ 155 1, /* numOfTxChains */ 156 1}; /* numOfRxChains */ 157 #endif /* WLAN_CHIP_VERSION_XXXX */ 158 159 /* 160 * wfc_util_qcom_is_default_mac 161 * 162 * 163 * 164 * return : it will return 1 if mac_add is default mac address, 165 * 2 if mac_add is RFT mac address 166 * or 0 if not. 167 */ 168 static int wfc_util_qcom_is_default_mac(char *mac_add) 169 { 170 #define WFC_UTIL_CFG_DEFAULT_MAC_RFT "00900CBACD88" 171 #define WFC_UTIL_CFG_DEFAULT_MAC_00 "000000000000" 172 #define WFC_UTIL_CFG_DEFAULT_MAC_FF "FFFFFFFFFFFF" 173 #define WFC_UTIL_CFG_DEFAULT_MAC_QCOM_I0 "000AF58989FF" 174 #define WFC_UTIL_CFG_DEFAULT_MAC_QCOM_I1 "000AF58989FE" 175 #define WFC_UTIL_CFG_DEFAULT_MAC_QCOM_I2 "000AF58989FD" 176 #define WFC_UTIL_CFG_DEFAULT_MAC_QCOM_I3 "000AF58989FC" 177 #define WFC_UTIL_CFG_DEFAULT_MAC_QCOM_AP "000AF58989EF" 178 179 int i, sZarray=0; 180 /* 181 * default mac address array 182 */ 183 char mac_add_buff[][WFC_UTIL_CFG_LENGHT_MAC_STRING+1] = { 184 {WFC_UTIL_CFG_DEFAULT_MAC_00}, 185 {WFC_UTIL_CFG_DEFAULT_MAC_FF}, 186 {WFC_UTIL_CFG_DEFAULT_MAC_QCOM_I0} 187 }; 188 189 sZarray = sizeof(mac_add_buff) / sizeof(mac_add_buff[0]); 190 191 for(i=0; i<sZarray ;i++) { 192 if(0 == strncmp(mac_add, mac_add_buff[i], WFC_UTIL_CFG_LENGHT_MAC_STRING)) { 193 wfc_util_log_error("This is default MAC address [%s]", mac_add_buff[i]); 194 return 1; 195 } 196 } 197 198 /* 199 if(1 == wfc_util_is_random_mac(mac_add)) { 200 wfc_util_log_error("This is Random MAC address"); 201 return 1; 202 } 203 */ 204 205 if(0 == strncmp(mac_add, WFC_UTIL_CFG_DEFAULT_MAC_RFT, WFC_UTIL_CFG_LENGHT_MAC_STRING)) { 206 wfc_util_log_error("This is RFT MAC address [%s]", WFC_UTIL_CFG_DEFAULT_MAC_RFT); 207 return 2; 208 } 209 210 return 0; 211 } 212 213 static void wfc_util_qcom_write_mac(char *mac_add) 214 { 215 /* 216 * Station Mode MAC Address 217 */ 218 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 219 WFC_UTIL_CFG_TAG_END_OF_CFG, 220 WFC_UTIL_CFG_TAG_MAC_ADDRESS, 221 WFC_UTIL_CFG_TAG_END_OF_LINE, 222 mac_add); 223 224 /* 225 * AP Mode MAC Address 226 */ 227 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 228 WFC_UTIL_CFG_TAG_END_OF_CFG, 229 WFC_UTIL_CFG_TAG_AP_MAC_ADDRESS, 230 WFC_UTIL_CFG_TAG_END_OF_LINE, 231 mac_add); 232 233 return; 234 } 235 236 /* 237 * When OTA is enabled, power save mode and L2 roaming trigger should be off 238 */ 239 static void wfc_util_qcom_write_ota_enable(void) 240 { 241 /* 242 * write Beacon Mode Power Save off and L2 Roaming off 243 */ 244 char *PowerSaveOff = "0"; 245 //char *L2RoamingOff = "0"; 246 char *Heartbeat24 = "120"; 247 248 char string_buff[5]; 249 250 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 251 WFC_UTIL_CFG_TAG_END_OF_CFG, 252 WFC_UTIL_CFG_TAG_IDLE_MODE_POWER_SAVE, 253 WFC_UTIL_CFG_TAG_END_OF_LINE, 254 PowerSaveOff); 255 256 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 257 WFC_UTIL_CFG_TAG_END_OF_CFG, 258 WFC_UTIL_CFG_TAG_POWER_SAVE, 259 WFC_UTIL_CFG_TAG_END_OF_LINE, 260 PowerSaveOff); 261 262 /* We don't need to change this becasue the default value of WFC_UTIL_CFG_TAG_L2Roaming is 0. 263 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 264 WFC_UTIL_CFG_TAG_END_OF_CFG, 265 WFC_UTIL_CFG_TAG_L2Roaming, 266 WFC_UTIL_CFG_TAG_END_OF_LINE, 267 L2RoamingOff); 268 */ 269 270 if(0 < wfc_util_fget_string(WFC_UTIL_CFG_FILE_NAME, 271 WFC_UTIL_CFG_TAG_END_OF_CFG, 272 WFC_UTIL_CFG_TAG_HEARTBEAT24, 273 WFC_UTIL_CFG_TAG_END_OF_LINE, 274 string_buff, 275 5)) { 276 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 277 WFC_UTIL_CFG_TAG_END_OF_CFG, 278 WFC_UTIL_CFG_TAG_HEARTBEAT24, 279 WFC_UTIL_CFG_TAG_END_OF_LINE, 280 Heartbeat24); 281 } else { 282 wfc_util_log_error("%s is not exist", WFC_UTIL_CFG_TAG_HEARTBEAT24); 283 } 284 285 return; 286 } 287 288 /* 289 * When OTA is enabled, power save mode and L2 roaming trigger should be off 290 */ 291 static void wfc_util_qcom_write_ota_disable(void) 292 { 293 /* 294 * write Beacon Mode Power Save on and L2 Roaming on 295 */ 296 char *PowerSaveOff = "1"; 297 //char *L2RoamingOff = "1"; 298 char *Heartbeat24 = "40"; 299 300 char string_buff[5]; 301 302 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 303 WFC_UTIL_CFG_TAG_END_OF_CFG, 304 WFC_UTIL_CFG_TAG_IDLE_MODE_POWER_SAVE, 305 WFC_UTIL_CFG_TAG_END_OF_LINE, 306 PowerSaveOff); 307 308 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 309 WFC_UTIL_CFG_TAG_END_OF_CFG, 310 WFC_UTIL_CFG_TAG_POWER_SAVE, 311 WFC_UTIL_CFG_TAG_END_OF_LINE, 312 PowerSaveOff); 313 314 /* We don't need to change this becasue the default value of WFC_UTIL_CFG_TAG_L2Roaming is 0. 315 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 316 WFC_UTIL_CFG_TAG_END_OF_CFG, 317 WFC_UTIL_CFG_TAG_L2Roaming, 318 WFC_UTIL_CFG_TAG_END_OF_LINE, 319 L2RoamingOff); 320 */ 321 322 if(0 < wfc_util_fget_string(WFC_UTIL_CFG_FILE_NAME, 323 WFC_UTIL_CFG_TAG_END_OF_CFG, 324 WFC_UTIL_CFG_TAG_HEARTBEAT24, 325 WFC_UTIL_CFG_TAG_END_OF_LINE, 326 string_buff, 327 5)) { 328 wfc_util_fset_string(WFC_UTIL_CFG_FILE_NAME, 329 WFC_UTIL_CFG_TAG_END_OF_CFG, 330 WFC_UTIL_CFG_TAG_HEARTBEAT24, 331 WFC_UTIL_CFG_TAG_END_OF_LINE, 332 Heartbeat24); 333 } else { 334 wfc_util_log_error("%s is not exist", WFC_UTIL_CFG_TAG_HEARTBEAT24); 335 } 336 337 return; 338 } 339 340 static void wfc_util_qcom_write_mac_to_bin(unsigned char *mac_add) 341 { 342 unsigned char nvValidityBitmap[WFC_UTIL_NV_BIN_HEADER_LENGTH]; 343 344 if(0 != wfc_util_ffile_check(WFC_UTIL_NV_BIN_FILE_NAME, 345 F_OK|R_OK|W_OK)) { 346 wfc_util_log_error("We don't access file [%s]", WFC_UTIL_NV_BIN_FILE_NAME); 347 return; 348 } 349 350 memset(nvValidityBitmap, 0, WFC_UTIL_NV_BIN_HEADER_LENGTH); 351 352 /* 353 * Write RFT MAC Address 354 */ 355 wfc_util_fset_buffer(WFC_UTIL_NV_BIN_FILE_NAME, 356 WFC_UTIL_NV_BIN_POS_MAC_ADDR, 357 mac_add, 358 WFC_UTIL_CFG_LENGHT_MAC); 359 360 /* 361 * Read NV validity bitmap 362 */ 363 if (0 < wfc_util_fget_buffer(WFC_UTIL_NV_BIN_FILE_NAME, 364 0, 365 WFC_UTIL_NV_BIN_HEADER_LENGTH, 366 nvValidityBitmap, 367 WFC_UTIL_NV_BIN_HEADER_LENGTH)){ 368 /* 369 * Check whether Fields bit(Bit 1) is set 370 */ 371 if (0x02 & nvValidityBitmap[0]) { 372 wfc_util_log_info("We don't need to write the default value for NvFilelds"); 373 } else { 374 /* 375 * Update the Fields bit(Bit 1) 376 */ 377 nvValidityBitmap[0] |= 0x02; 378 wfc_util_fset_buffer(WFC_UTIL_NV_BIN_FILE_NAME, 379 0, 380 nvValidityBitmap, 381 WFC_UTIL_NV_BIN_HEADER_LENGTH); 382 383 /* 384 * Write the default value for NvFilelds 385 */ 386 wfc_util_fset_buffer(WFC_UTIL_NV_BIN_FILE_NAME, 387 WFC_UTIL_NV_BIN_POS_PRODUCT_ID, 388 nvFilelds_default, 389 6); 390 } 391 } else { 392 wfc_util_log_error("Read Fail nvValidityBitmap"); 393 } 394 395 return; 396 } 397 398 /* 399 * wfc_util_qcom_reset_mac_to_bin 400 * 401 * reset the mac address of nv bin file 402 * 403 * return : void 404 */ 405 static void wfc_util_qcom_reset_mac_to_bin(void) 406 { 407 unsigned char mac_addr[WFC_UTIL_CFG_LENGHT_MAC]; 408 409 if(0 != wfc_util_ffile_check(WFC_UTIL_NV_BIN_FILE_NAME, 410 F_OK|R_OK|W_OK)) { 411 wfc_util_log_error("We don't access file [%s]", WFC_UTIL_NV_BIN_FILE_NAME); 412 return; 413 } 414 415 if(0 < wfc_util_fget_buffer(WFC_UTIL_NV_BIN_FILE_NAME, 416 WFC_UTIL_NV_BIN_POS_MAC_ADDR, 417 WFC_UTIL_CFG_LENGHT_MAC, 418 mac_addr, 419 WFC_UTIL_CFG_LENGHT_MAC)) { 420 if(0x00 == mac_addr[0] && 0x00 == mac_addr[1] && 0x00 == mac_addr[2] && 421 0x00 == mac_addr[3] && 0x00 == mac_addr[4] && 0x00 == mac_addr[5]) 422 { 423 return; 424 } 425 } 426 427 memset(mac_addr, 0, WFC_UTIL_CFG_LENGHT_MAC); 428 429 wfc_util_fset_buffer(WFC_UTIL_NV_BIN_FILE_NAME, 430 WFC_UTIL_NV_BIN_POS_MAC_ADDR, 431 mac_addr, 432 WFC_UTIL_CFG_LENGHT_MAC); 433 434 return; 435 } 436 437 static int wfc_util_qcom_write_mac_process(unsigned char *nv_mac_addr, char *mac_add_buff) 438 { 439 char nv_mac_add_buff[WFC_UTIL_CFG_LENGHT_MAC_STRING+1]; 440 int is_default_nv_mac = 0; 441 int is_same_mac = -1; 442 443 if (NULL == nv_mac_addr) { 444 return 0; 445 } 446 447 wfc_util_htoa(nv_mac_addr, WFC_UTIL_CFG_LENGHT_MAC, 448 nv_mac_add_buff, WFC_UTIL_CFG_LENGHT_MAC_STRING+1); 449 450 is_default_nv_mac = wfc_util_qcom_is_default_mac(nv_mac_add_buff); 451 452 is_same_mac = strncmp(mac_add_buff, nv_mac_add_buff, WFC_UTIL_CFG_LENGHT_MAC_STRING); 453 454 /* 455 * 1. nv mac address is not a default mac address 456 * 2. same with mac address of config file 457 */ 458 if (((!is_default_nv_mac) && (0==is_same_mac)) || 459 /* 460 * 1. nv mac address is RFT mac address 461 * 2. same with mac address of config file 462 */ 463 ((2==is_default_nv_mac) && (0==is_same_mac)) 464 ) { 465 return 1; 466 } 467 /* 468 * 1. nv mac address not a default mac address excepting RFT mac address 469 * 2. does not same with mac address of config file 470 */ 471 else if ((1!=is_default_nv_mac) && (0!=is_same_mac)) { 472 wfc_util_log_error("Change %s%s", WFC_UTIL_CFG_TAG_MAC_ADDRESS, nv_mac_add_buff); 473 /* 474 * Update MAC address 475 */ 476 wfc_util_qcom_write_mac(nv_mac_add_buff); 477 478 #ifdef WFC_UTIL_FEATURE_DO_NOT_WRITE_MAC_TO_BIN 479 /* 480 * Write RFT MAC address to nv.bin 481 */ 482 if (2==is_default_nv_mac) { 483 wfc_util_qcom_write_mac_to_bin(nv_mac_addr); 484 /* 485 * reset mac address of nv.bin if nv_mac_addr is not RFT mac address 486 */ 487 } else { 488 wfc_util_qcom_reset_mac_to_bin(); 489 } 490 #else /* WFC_UTIL_FEATURE_DO_NOT_WRITE_MAC_TO_BIN */ 491 /* 492 * Write MAC address to nv.bin 493 */ 494 wfc_util_qcom_write_mac_to_bin(nv_mac_addr); 495 #endif /* WFC_UTIL_FEATURE_DO_NOT_WRITE_MAC_TO_BIN */ 496 497 return 1; 498 } 499 500 return 0; 501 } 502 503 static void wfc_util_qcom_create_random_mac(void) 504 { 505 unsigned char random_mac_addr[WFC_UTIL_CFG_LENGHT_MAC]; 506 char mac_add_buff[WFC_UTIL_CFG_LENGHT_MAC_STRING+1]; 507 508 wfc_util_log_info("wfc_util_qcom_create_random_mac"); 509 510 wfc_util_random_mac(random_mac_addr); 511 512 wfc_util_htoa(random_mac_addr, WFC_UTIL_CFG_LENGHT_MAC, mac_add_buff, WFC_UTIL_CFG_LENGHT_MAC_STRING+1); 513 514 wfc_util_qcom_write_mac(mac_add_buff); 515 516 #ifdef WFC_UTIL_FEATURE_DO_NOT_WRITE_MAC_TO_BIN 517 wfc_util_qcom_reset_mac_to_bin(); 518 #else /* WFC_UTIL_FEATURE_DO_NOT_WRITE_MAC_TO_BIN */ 519 wfc_util_qcom_write_mac_to_bin(random_mac_addr); 520 #endif /* WFC_UTIL_FEATURE_DO_NOT_WRITE_MAC_TO_BIN */ 521 522 return; 523 } 524 525 /* 526 * wfc_util_qcom_check_config 527 * 528 * check the qcom wlan driver config file 529 * 530 * return : it will return 0 if procedure is success 531 * or will return -1 if not. 532 */ 533 int wfc_util_qcom_check_config(unsigned char *nv_mac_addr) 534 { 535 char mac_add_buff[WFC_UTIL_CFG_LENGHT_MAC_STRING+1]; 536 537 /* make sure driver config file exists */ 538 if(0 > wfc_util_ffile_check_copy(WFC_UTIL_CFG_FILE_NAME, 539 WFC_UTIL_CFG_TEMPFILE_NAME, 540 0660, 541 AID_SYSTEM, 542 /* we use "radio" for gid to access from "rild" for AT cmd. */ 543 AID_WIFI/*AID_WIFI*/)) { 544 wfc_util_log_error("Fail to Access [%s]", WFC_UTIL_CFG_FILE_NAME); 545 return -1; 546 } 547 548 #ifdef WFC_UTIL_FEAUTRE_COPY_NV_BIN 549 if(0 > wfc_util_ffile_check_copy(WFC_UTIL_NV_BIN_FILE_NAME, 550 WFC_UTIL_NV_BIN_TEMPFILE_NAME, 551 0660, 552 AID_SYSTEM, 553 /* we use "radio" for gid to access from "rild" for AT cmd. */ 554 AID_WIFI/*AID_WIFI*/)) { 555 wfc_util_log_error("Fail to Access [%s]", WFC_UTIL_NV_BIN_FILE_NAME); 556 return -1; 557 } 558 #endif /* WFC_UTIL_FEAUTRE_COPY_NV_BIN */ 559 560 /* 561 * Read MAC address from config file 562 */ 563 if(0 < wfc_util_fget_string(WFC_UTIL_CFG_FILE_NAME, 564 WFC_UTIL_CFG_TAG_END_OF_CFG, 565 WFC_UTIL_CFG_TAG_MAC_ADDRESS, 566 WFC_UTIL_CFG_TAG_END_OF_LINE, 567 mac_add_buff, 568 WFC_UTIL_CFG_LENGHT_MAC_STRING+1)) { 569 wfc_util_log_info("%s%s", WFC_UTIL_CFG_TAG_MAC_ADDRESS, mac_add_buff); 570 571 /* 572 * Write nv mac address 573 */ 574 if (1 != wfc_util_qcom_write_mac_process(nv_mac_addr, mac_add_buff)) { 575 /* 576 * Check whether this is default mac address or not 577 */ 578 if (wfc_util_qcom_is_default_mac(mac_add_buff)) { 579 /* 580 * Create random MAC address 581 */ 582 wfc_util_qcom_create_random_mac(); 583 } 584 } 585 } else { 586 wfc_util_log_error("%s does not have mac address", WFC_UTIL_CFG_FILE_NAME); 587 588 memset( mac_add_buff, 0, WFC_UTIL_CFG_LENGHT_MAC_STRING+1 ); 589 590 /* 591 * Write nv mac address 592 */ 593 if (1 != wfc_util_qcom_write_mac_process(nv_mac_addr, mac_add_buff)) { 594 /* 595 * Create random MAC address 596 */ 597 wfc_util_qcom_create_random_mac(); 598 } 599 } 600 601 return 0; 602 } 603 604 /* 605 * wfc_util_qcom_reset_mac 606 * 607 * reset the mac address of config file 608 * 609 * return : void 610 */ 611 void wfc_util_qcom_reset_mac(void) 612 { 613 wfc_util_qcom_write_mac("000000000000"); 614 615 wfc_util_qcom_reset_mac_to_bin(); 616 617 return; 618 } 619 620 /* 621 * wfc_util_qcom_ota_enable 622 * 623 * enable ota mode by reconfiguring BMPS and L2Roaming 624 * 625 * return : int (boolean) 626 */ 627 int wfc_util_qcom_ota_enable(void) 628 { 629 wfc_util_qcom_write_ota_enable(); 630 return 1; 631 } 632 633 /* 634 * wfc_util_qcom_ota_disable 635 * 636 * disable ota mode by reconfiguring BMPS and L2Roaming 637 * 638 * return : int (boolean) 639 */ 640 int wfc_util_qcom_ota_disable(void) 641 { 642 wfc_util_qcom_write_ota_disable(); 643 return 1; 644 } 645 646 /* 647 * wfc_util_qcom_checkt_roaming_off 648 * 649 * Check L2Roaming configuration 650 * 651 * return : int (boolean) 652 */ 653 int wfc_util_qcom_checkt_roaming_off(void) 654 { 655 char string_buff[5]; 656 /* 657 * check whether OTA test is enabled or not. 658 */ 659 if(0 < wfc_util_fget_string(WFC_UTIL_CFG_FILE_NAME, 660 WFC_UTIL_CFG_TAG_END_OF_CFG, 661 //WFC_UTIL_CFG_TAG_L2Roaming, 662 WFC_UTIL_CFG_TAG_POWER_SAVE, 663 WFC_UTIL_CFG_TAG_END_OF_LINE, 664 string_buff, 665 5)) { 666 //wfc_util_log_info("%s%s", WFC_UTIL_CFG_TAG_L2Roaming, string_buff); 667 wfc_util_log_info("%s%s", WFC_UTIL_CFG_TAG_POWER_SAVE, string_buff); 668 if(0 == strncmp(string_buff, "0", 1)) { 669 return 1; 670 } 671 } 672 return 0; 673 } 674 675 #endif /* CONFIG_LGE_WLAN_QCOM_PATCH */ 676 677