int dhd_check_module_mac(dhd_pub_t *dhd, struct ether_addr *mac) { int ret = -1; unsigned char cis_buf[250] = {0}; unsigned char mac_buf[20] = {0}; unsigned char otp_mac_buf[20] = {0}; const char *macfilepath = MACINFO_EFS; /* Try reading out from CIS */ cis_rw_t *cish = (cis_rw_t *)&cis_buf[8]; struct file *fp_mac = NULL; cish->source = 0; cish->byteoff = 0; cish->nbytes = sizeof(cis_buf); strcpy(cis_buf, "cisdump"); ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, cis_buf, sizeof(cis_buf), 0, 0); if (ret < 0) { DHD_TRACE(("%s: CIS reading failed, err=%d\n", __func__, ret)); sprintf(otp_mac_buf, "%02X:%02X:%02X:%02X:%02X:%02X\n", mac->octet[0], mac->octet[1], mac->octet[2], mac->octet[3], mac->octet[4], mac->octet[5]); DHD_ERROR(("%s: Check module mac by legacy FW : %02X:%02X:%02X\n", __func__, mac->octet[0], mac->octet[4], mac->octet[5])); } else { unsigned char mac_id[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; #ifdef DUMP_CIS dump_cis(cis_buf, 48); #endif mac_id[0] = cis_buf[CIS_MAC_OFFSET]; mac_id[1] = cis_buf[CIS_MAC_OFFSET + 1]; mac_id[2] = cis_buf[CIS_MAC_OFFSET + 2]; mac_id[3] = cis_buf[CIS_MAC_OFFSET + 3]; mac_id[4] = cis_buf[CIS_MAC_OFFSET + 4]; mac_id[5] = cis_buf[CIS_MAC_OFFSET + 5]; sprintf(otp_mac_buf, "%02X:%02X:%02X:%02X:%02X:%02X\n", mac_id[0], mac_id[1], mac_id[2], mac_id[3], mac_id[4], mac_id[5]); DHD_ERROR(("[WIFI]mac_id is setted from OTP \n")); } fp_mac = filp_open(macfilepath, O_RDONLY, 0); if (!IS_ERR(fp_mac)) { DHD_ERROR(("[WIFI]Check Mac address in .mac.info \n")); kernel_read(fp_mac, fp_mac->f_pos, mac_buf, sizeof(mac_buf)); filp_close(fp_mac, NULL); if (strncmp(mac_buf, otp_mac_buf, 17) != 0) { DHD_ERROR(("[WIFI]file MAC is wrong. Write OTP MAC in .mac.info \n")); dhd_write_mac_file(macfilepath, otp_mac_buf, sizeof(otp_mac_buf)); } } return ret; }
int check_module_cid(dhd_pub_t *dhd) { int ret = -1; unsigned char cis_buf[128] = {0}; unsigned char cid_buf[10] = {0}; const char* cidfilepath = "/data/.cid.info"; /* Try reading out from CIS */ cis_rw_t *cish = (cis_rw_t *)&cis_buf[8]; struct file *fp_cid = NULL; fp_cid = filp_open(cidfilepath, O_RDONLY, 0); if (!IS_ERR(fp_cid)) { kernel_read(fp_cid, fp_cid->f_pos, cid_buf, sizeof(cid_buf)); if(strstr(cid_buf,"samsung")||strstr(cid_buf,"murata")||strstr(cid_buf,"semcove")) { /* file does exist, just return */ filp_close(fp_cid, NULL); return 0; } DHD_ERROR(("[WIFI].cid.info file already exists but it contains an unknown id [%s]\n", cid_buf)); } cish->source = 0; cish->byteoff = 0; cish->nbytes = sizeof(cis_buf); strcpy(cis_buf, "cisdump"); ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, cis_buf, sizeof(cis_buf), 0, 0); if (ret < 0) { DHD_ERROR(("%s: CIS reading failed, err=%d\n", __FUNCTION__, ret)); } else { unsigned char id[4] = {0x80, 0x06, 0x81, 0x00}; unsigned char id_swb42a[4] = {0x80, 0x02, 0x81, 0x99}; //SWB_42A #ifdef DUMP_CIS dump_cis(cis_buf, 48); #endif if (memcmp(&cis_buf[CIS_CID_OFFSET], id, 4) == 0) { DHD_ERROR(("CID MATCH FOUND\n")); write_cid_file(cidfilepath, "murata", 6); } else if (memcmp(&cis_buf[CIS_CID_OFFSET], id_swb42a, 4) == 0) { //SWB_42A DHD_ERROR(("CID MATCH FOUND semcove \n")); write_cid_file(cidfilepath, "semcove", 7); } else { DHD_ERROR(("CID MISMATCH 0x%02X 0x%02X 0x%02X 0x%02X\n", cis_buf[CIS_CID_OFFSET], cis_buf[CIS_CID_OFFSET+1], cis_buf[CIS_CID_OFFSET+2], cis_buf[CIS_CID_OFFSET+3])); write_cid_file(cidfilepath, "samsung", 7); } } return ret; }
int dhd_check_module_mac(dhd_pub_t *dhd) { int ret = -1; unsigned char cis_buf[250] = {0}; unsigned char mac_buf[20] = {0}; const char *macfilepath = "/efs/wifi/.mac.info"; /* Try reading out from CIS */ cis_rw_t *cish = (cis_rw_t *)&cis_buf[8]; struct file *fp_mac = NULL; fp_mac = filp_open(macfilepath, O_RDONLY, 0); if (!IS_ERR(fp_mac)) { kernel_read(fp_mac, fp_mac->f_pos, mac_buf, sizeof(mac_buf)); /*DHD_ERROR(("[WIFI].mac.info file already exist : [%s]\n", mac_buf));*/ return 0; } cish->source = 0; cish->byteoff = 0; cish->nbytes = sizeof(cis_buf); strcpy(cis_buf, "cisdump"); ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, cis_buf, sizeof(cis_buf), 0, 0); if (ret < 0) { DHD_ERROR(("%s: CIS reading failed, err=%d\n", __func__, ret)); } else { unsigned char mac_id[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; #ifdef DUMP_CIS dump_cis(cis_buf, 48); #endif mac_id[0] = cis_buf[CIS_MAC_OFFSET]; mac_id[1] = cis_buf[CIS_MAC_OFFSET + 1]; mac_id[2] = cis_buf[CIS_MAC_OFFSET + 2]; mac_id[3] = cis_buf[CIS_MAC_OFFSET + 3]; mac_id[4] = cis_buf[CIS_MAC_OFFSET + 4]; mac_id[5] = cis_buf[CIS_MAC_OFFSET + 5]; sprintf(mac_buf, "%02X:%02X:%02X:%02X:%02X:%02X\n", mac_id[0], mac_id[1], mac_id[2], mac_id[3], mac_id[4], mac_id[5]); /*DHD_ERROR(("[WIFI]mac_id is setted from OTP: [%s]\n", mac_buf));*/ dhd_write_mac_file(macfilepath, mac_buf, sizeof(mac_buf)); } return ret; }
int dhd_check_module_cid(dhd_pub_t *dhd) { int ret = -1; #ifdef BCM4334_CHIP unsigned char cis_buf[250] = {0}; const char *revfilepath = REVINFO; int flag_b3 = 0; #else unsigned char cis_buf[128] = {0}; #endif const char *cidfilepath = CIDINFO; /* Try reading out from CIS */ cis_rw_t *cish = (cis_rw_t *)&cis_buf[8]; cish->source = 0; cish->byteoff = 0; cish->nbytes = sizeof(cis_buf); strcpy(cis_buf, "cisdump"); ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, cis_buf, sizeof(cis_buf), 0, 0); if (ret < 0) { DHD_TRACE(("%s: CIS reading failed, err=%d\n", __FUNCTION__, ret)); return ret; } else { #ifdef BCM4334_CHIP unsigned char semco_id[4] = {0x00, 0x00, 0x33, 0x33}; /* for SHARP FEM(new) */ unsigned char semco_id_sh[4] = {0x00, 0x00, 0xFB, 0x50}; DHD_ERROR(("%s: CIS reading success, ret=%d\n", __FUNCTION__, ret)); #ifdef DUMP_CIS dump_cis(cis_buf, 48); #endif if (memcmp(&cis_buf[CIS_CID_OFFSET], semco_id, 4) == 0) { DHD_ERROR(("CID MATCH FOUND : Semco, " "0x%02X 0x%02X 0x%02X 0x%02X\n", cis_buf[CIS_CID_OFFSET], cis_buf[CIS_CID_OFFSET+1], cis_buf[CIS_CID_OFFSET+2], cis_buf[CIS_CID_OFFSET+3])); dhd_write_cid_file(cidfilepath, "semco", 5); } else if (memcmp(&cis_buf[CIS_CID_OFFSET], semco_id_sh, 4) == 0) { DHD_ERROR(("CIS MATCH FOUND : Semco_sh, " "0x%02X 0x%02X 0x%02X 0x%02X\n", cis_buf[CIS_CID_OFFSET], cis_buf[CIS_CID_OFFSET+1], cis_buf[CIS_CID_OFFSET+2], cis_buf[CIS_CID_OFFSET+3])); dhd_write_cid_file(cidfilepath, "semcosh", 7); } else { DHD_ERROR(("CID MATCH FOUND : Murata, " "0x%02X 0x%02X 0x%02X 0x%02X\n", cis_buf[CIS_CID_OFFSET], cis_buf[CIS_CID_OFFSET+1], cis_buf[CIS_CID_OFFSET+2], cis_buf[CIS_CID_OFFSET+3])); dhd_write_cid_file(cidfilepath, "murata", 6); } /* Try reading out from OTP to distinguish B2 or B3 */ memset(cis_buf, 0, sizeof(cis_buf)); cish = (cis_rw_t *)&cis_buf[8]; cish->source = 0; cish->byteoff = 0; cish->nbytes = sizeof(cis_buf); strcpy(cis_buf, "otpdump"); ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, cis_buf, sizeof(cis_buf), 0, 0); if (ret < 0) { DHD_ERROR(("%s: OTP reading failed, err=%d\n", __FUNCTION__, ret)); return ret; } /* otp 33th character is identifier for 4334B3 */ cis_buf[34] = '\0'; flag_b3 = bcm_atoi(&cis_buf[33]); if (flag_b3 & 0x1) { DHD_ERROR(("REV MATCH FOUND : 4334B3, %c\n", cis_buf[33])); dhd_write_cid_file(revfilepath, "4334B3", 6); } #else /* BCM4330_CHIP */ unsigned char murata_id[4] = {0x80, 0x06, 0x81, 0x00}; unsigned char semco_ve[4] = {0x80, 0x02, 0x81, 0x99}; #ifdef DUMP_CIS dhd_dump_cis(cis_buf, 48); #endif if (memcmp(&cis_buf[CIS_CID_OFFSET], murata_id, 4) == 0) { DHD_ERROR(("CID MATCH FOUND : Murata\n")); dhd_write_cid_file(cidfilepath, "murata", 6); } else if (memcmp(&cis_buf[CIS_CID_OFFSET], semco_ve, 4) == 0) { DHD_ERROR(("CID MATCH FOUND : Semco VE\n")); dhd_write_cid_file(cidfilepath, "semcove", 7); } else { DHD_ERROR(("CID MISMATCH" " 0x%02X 0x%02X 0x%02X 0x%02X\n", cis_buf[CIS_CID_OFFSET], cis_buf[CIS_CID_OFFSET + 1], cis_buf[CIS_CID_OFFSET + 2], cis_buf[CIS_CID_OFFSET + 3])); dhd_write_cid_file(cidfilepath, "samsung", 7); } #endif /* BCM4334_CHIP */ DHD_ERROR(("%s: CIS write success, err=%d\n", __FUNCTION__, ret)); } return ret; }