Ejemplo n.º 1
0
void __init ath6kl_sdio_init_msm(void)
{
	char buf[3];
	int length;
	int ret;

	sema_init(&wifi_control_sem, 1);
	down(&wifi_control_sem);

	ret = platform_driver_probe(&wifi_device, wifi_probe);
	if (ret) {
		printk(KERN_INFO "platform_driver_register failed\n");
		return;
	}

	/* Waiting callback after platform_driver_register */
	if (down_timeout(&wifi_control_sem,  msecs_to_jiffies(5000)) != 0) {
		ret = -EINVAL;
		printk(KERN_INFO "platform_driver_register timeout\n");
		return;
	}

	length = snprintf(buf, sizeof(buf), "%d\n", 1 ? 1 : 0);
	android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV
		"/polling", NULL, buf, length);
	length = snprintf(buf, sizeof(buf), "%d\n", 0 ? 1 : 0);
	android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV
		"/polling", NULL, buf, length);

	mdelay(500);
}
Ejemplo n.º 2
0
static int ath6kl_sdio_remove(struct platform_device *pdev)
{
	char buf[3];
	int length;
	struct ath6kl_platform_data *pdata = platform_get_drvdata(pdev);

	if (pdata->wifi_chip_pwd != NULL &&
		!IS_ERR(pdata->wifi_chip_pwd->reg))  {

		ath6kl_platform_power(pdata, 0);
		regulator_put(pdata->wifi_chip_pwd->reg);

		if (pdata->wifi_vddpa != NULL &&
			pdata->wifi_vddpa->reg)
			regulator_put(pdata->wifi_vddpa->reg);

		if (pdata->wifi_vddio != NULL &&
			pdata->wifi_vddio->reg)
			regulator_put(pdata->wifi_vddio->reg);

		mdelay(50);
		length = snprintf(buf, sizeof(buf), "%d\n", 1 ? 1 : 0);
		android_readwrite_file("/sys/devices/msm_sdcc.3/polling",
			NULL, buf, length);
		length = snprintf(buf, sizeof(buf), "%d\n", 0 ? 1 : 0);
		android_readwrite_file("/sys/devices/msm_sdcc.3/polling",
			NULL, buf, length);
		mdelay(500);
	}



	up(&wifi_control_sem);
	return 0;
}
Ejemplo n.º 3
0
void __exit ath6kl_sdio_exit_msm(void)
{
	char buf[3];
	int length;
	int ret;

	platform_driver_unregister(&wifi_device);

	/* Waiting callback after platform_driver_register */
	if (down_timeout(&wifi_control_sem,  msecs_to_jiffies(5000)) != 0) {
		ret = -EINVAL;
		printk(KERN_INFO "platform_driver_unregister timeout\n");
		return;
	}

	length = snprintf(buf, sizeof(buf), "%d\n", 1 ? 1 : 0);
	/* fall back to polling */
	android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV
		"/polling", NULL, buf, length);
	length = snprintf(buf, sizeof(buf), "%d\n", 0 ? 1 : 0);
	/* fall back to polling */
	android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV
		"/polling", NULL, buf, length);
	mdelay(1000);

}
Ejemplo n.º 4
0
void android_ar6k_check_wow_status(AR_SOFTC_T *ar, struct sk_buff *skb, A_BOOL isEvent)
{
#ifdef CONFIG_PM
    if (ar->arWowState!=WOW_STATE_NONE) {
        if (ar->arWowState==WOW_STATE_SUSPENDING) {
            AR_DEBUG_PRINTF(ATH_DEBUG_SUSPEND,("%s: Received IRQ while we are wow suspending!!!\n", __func__));
            return;
        }
        /* Wow resume from irq interrupt */
        AR_DEBUG_PRINTF(ATH_DEBUG_SUSPEND, ("%s: WoW resume from irq thread status %d\n", 
                        __func__, ar->arOsPowerCtrl));
        ar6000_wow_resume(ar);
        ar->arOsPowerCtrl = WLAN_PWR_CTRL_UP;
    } else if (screen_is_off && skb && ar->arConnected) {
        A_BOOL needWake = FALSE;
        if (isEvent) {
            if (A_NETBUF_LEN(skb) >= sizeof(A_UINT16)) {
                A_UINT16 cmd = *(const A_UINT16 *)A_NETBUF_DATA(skb);
                switch (cmd) {
                case WMI_CONNECT_EVENTID:
                case WMI_DISCONNECT_EVENTID:
                    needWake = TRUE;
                    break;
                default:
                    /* dont wake lock the system for other event */
                    break;
                }
            }
        } else if (A_NETBUF_LEN(skb) >= sizeof(ATH_MAC_HDR)) {
            ATH_MAC_HDR *datap = (ATH_MAC_HDR *)A_NETBUF_DATA(skb);
            if (!IEEE80211_IS_MULTICAST(datap->dstMac)) {
                switch (A_BE2CPU16(datap->typeOrLen)) {
                case 0x0800: /* IP */
                case 0x888e: /* EAPOL */
                case 0x88c7: /* RSN_PREAUTH */
                case 0x88b4: /* WAPI */
                     needWake = TRUE;
                     break;
                case 0x0806: /* ARP is not important to hold wake lock */
                default:
                    break;
                }
            }
        }
        if (needWake) {
            /* keep host wake up if there is any event and packate comming in*/
            wake_lock_timeout(&ar6k_wow_wake_lock, 3*HZ);
            if (wowledon) {
                char buf[32];
                int len = sprintf(buf, "on");         
                android_readwrite_file("/sys/power/state", NULL, buf, len);

                len = sprintf(buf, "%d", 127);
                android_readwrite_file("/sys/class/leds/lcd-backlight/brightness", 
                                       NULL, buf,len);                    
            }
        }
    }
#endif /* CONFIG_PM */
}
Ejemplo n.º 5
0
int android_request_firmware(const struct firmware **firmware_p, const char *name,
                     struct device *device)
{
    int ret = 0;
    struct firmware *firmware;
    char filename[256];
    const char *raw_filename = name;
	*firmware_p = firmware = A_MALLOC(sizeof(*firmware));
    if (!firmware) 
		return -ENOMEM;
    A_MEMZERO(firmware, sizeof(*firmware));
	sprintf(filename, "%s/%s", fwpath, raw_filename);
#ifdef TARGET_EUROPA
    if (strcmp(raw_filename, "softmac")==0) {
        sprintf(filename, "/data/.nvmac.info");
    }
#endif /* TARGET_EUROPA */
    do {
        size_t length, bufsize, bmisize;

        if ( (ret=android_readwrite_file(filename, NULL, NULL, 0)) < 0) {
            break;
        } else {
            length = ret;
        }
    
        bufsize = ALIGN(length, PAGE_SIZE);
        bmisize = A_ROUND_UP(length, 4);
        bufsize = max(bmisize, bufsize);
        firmware->data = vmalloc(bufsize);
        firmware->size = length;
        if (!firmware->data) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: Cannot allocate buffer for firmware\n", __FUNCTION__));
            ret = -ENOMEM;
            break;
        }
    
        if ( (ret=android_readwrite_file(filename, (char*)firmware->data, NULL, length)) != length) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: file read error, ret %d request %d\n", __FUNCTION__, ret, length));
            ret = -1;
            break;
        }
    
    } while (0);

    if (ret<0) {
        if (firmware) {
            if (firmware->data)
                vfree(firmware->data);
            A_FREE(firmware);
        }
        *firmware_p = NULL;
    } else {
        ret = 0;
    }
    return ret;    
}
Ejemplo n.º 6
0
static int ath6kl_sdio_probe(struct platform_device *pdev)
{
	struct ath6kl_platform_data *pdata = NULL;
	struct device *dev = &pdev->dev;
	int ret = 0;
	int length;
	char buf[3];

	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);

	if (!pdata) {
		ath6kl_err("%s: Could not allocate memory for platform data\n",
				__func__);
		up(&wifi_control_sem);
		return -ENOMEM;
	}

	if (ath6kl_dt_parse_vreg_info(dev, &pdata->wifi_chip_pwd,
		"qca,wifi-chip-pwd") != 0) {
		ath6kl_err("%s: parse vreg info error\n", __func__);
		goto err;
	}

	pdata->pdev = pdev;
	platform_set_drvdata(pdev, pdata);
	gpdata = pdata;

	if (pdata->wifi_chip_pwd != NULL) {
		ret = ath6kl_platform_power(pdata, 1);
		if (ret == 0) {
			mdelay(50);
			length = snprintf(buf, sizeof(buf), "%d\n", 1 ? 1 : 0);
			android_readwrite_file(
				"/sys/devices/msm_sdcc.3/polling",
					NULL, buf, length);
			length = snprintf(buf, sizeof(buf), "%d\n", 0 ? 1 : 0);
			android_readwrite_file(
				"/sys/devices/msm_sdcc.3/polling",
					NULL, buf, length);
			mdelay(500);
		}
	}

	up(&wifi_control_sem);
	return ret;

err:
	if (pdata != NULL)
		devm_kfree(dev, pdata);

	up(&wifi_control_sem);
	return -EINVAL;
}
Ejemplo n.º 7
0
int android_request_firmware(const struct firmware **firmware_p, const char *name,
                     struct device *device)
{
    int ret = 0;
    struct firmware *firmware;
    char filename[256];
    const char *raw_filename = name;
	*firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
    if (!firmware) 
		return -ENOMEM;
	sprintf(filename, "%s/%s", fwpath, raw_filename);
    do {
        size_t length, bufsize, bmisize;

        if ( (ret=android_readwrite_file(filename, NULL, NULL, 0)) < 0) {
            break;
        } else {
            length = ret;
        }
    
        bufsize = ALIGN(length, PAGE_SIZE);
        bmisize = A_ROUND_UP(length, 4);
        bufsize = max(bmisize, bufsize);
        firmware->data = vmalloc(bufsize);
        firmware->size = bmisize;
        if (!firmware->data) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: Cannot allocate buffer for firmware\n", __FUNCTION__));
            ret = -ENOMEM;
            break;
        }
    
        if ( (ret=android_readwrite_file(filename, (char*)firmware->data, NULL, length)) != length) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: file read error, ret %d request %d\n", __FUNCTION__, ret, length));
            ret = -1;
            break;
        }
    
    } while (0);

    if (ret<0) {
        if (firmware) {
            if (firmware->data)
                vfree(firmware->data);
            kfree(firmware);
        }
        *firmware_p = NULL;
    } else {
        ret = 0;
    }
    return ret;    
}
Ejemplo n.º 8
0
void __init ath6kl_sdio_init_msm(void)
{
	char buf[3];
	int length;

	length = snprintf(buf, sizeof(buf), "%d\n", 1 ? 1 : 0);
	android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV
		"/polling", NULL, buf, length);
	length = snprintf(buf, sizeof(buf), "%d\n", 0 ? 1 : 0);
	android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV
		"/polling", NULL, buf, length);

	mdelay(500);
}
Ejemplo n.º 9
0
/* Useful for qualcom platform to detect our wlan card for mmc stack */
static void ar6000_enable_mmchost_detect_change(int enable)
{
#ifdef CONFIG_MMC_MSM
#define MMC_MSM_DEV "msm_sdcc.1"
    char buf[3];
    int length;
    length = snprintf(buf, sizeof(buf), "%d\n", enable ? 1 : 0);
    if (android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV "/detect_change", 
                               NULL, buf, length) < 0) {
        /* fall back to polling */
        android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV "/polling", NULL, buf, length);
    }
#endif
}
Ejemplo n.º 10
0
int ath6kl_hsic_bind(int bind)
{
	char buf[16];
	int length;

	ath6kl_dbg(ATH6KL_DBG_BOOT, "%s, bind: %d\n", __func__, bind);

	if (bind) {
		length = snprintf(buf, sizeof(buf), "%s\n", "msm_hsic_host");

		android_readwrite_file(
			"/sys/bus/platform/drivers/msm_hsic_host/bind",
			NULL, buf, length);
	} else {
		length = snprintf(buf, sizeof(buf), "%s\n", "msm_hsic_host");

		android_readwrite_file(
			"/sys/bus/platform/drivers/msm_hsic_host/unbind",
			NULL, buf, length);
	}

	return 0;
}
Ejemplo n.º 11
0
/* Useful for qualcom platform to detect our wlan card for mmc stack */
static void ar6000_enable_mmchost_detect_change(int enable)
{
#ifdef CONFIG_MMC_MSM
#if defined(CONFIG_MMC_MSM) && defined(CONFIG_ARCH_MSM7X27) && defined(CONFIG_MSM_SOC_REV_A)
#define MMC_MSM_DEV "msm_sdcc.2"
#else
#define MMC_MSM_DEV "msm_sdcc.1"
#endif
    char buf[3];
    int length;

    if (!enable_mmc_host_detect_change) {
        return;
    }
    length = snprintf(buf, sizeof(buf), "%d\n", enable ? 1 : 0);
    android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV "/polling", NULL, buf, length);
    A_MDELAY(50);
#endif
}
Ejemplo n.º 12
0
int sip_parse_events(struct esp_sip *sip, u8 *buf)
{
        struct sip_hdr *hdr = (struct sip_hdr *)buf;

        switch (hdr->c_evtid) {
	case SIP_EVT_TARGET_ON: {
		/* use rx work queue to send... */
		if (atomic_read(&sip->state) == SIP_PREPARE_BOOT || atomic_read(&sip->state) == SIP_BOOT) {
			atomic_set(&sip->state, SIP_SEND_INIT);
			queue_work(sip->epub->esp_wkq, &sip->rx_process_work);
		} else {
			esp_dbg(ESP_DBG_ERROR, "%s boot during wrong state %d\n", __func__, atomic_read(&sip->state));
		}
                break;
	}

        case SIP_EVT_BOOTUP: {
           	struct sip_evt_bootup2 *bootup_evt = (struct sip_evt_bootup2 *)(buf + SIP_CTRL_HDR_LEN);
		if (sip->rawbuf)
                	kfree(sip->rawbuf);
		
		sip_post_init(sip, bootup_evt);
		
		if (gl_bootup_cplx)	
			complete(gl_bootup_cplx);
                
		break;
        }
	case SIP_EVT_RESETTING:{
        sip->epub->wait_reset = 1;                       
        if (gl_bootup_cplx)	
			complete(gl_bootup_cplx);
		break;
	}
	case SIP_EVT_SLEEP:{
		//atomic_set(&sip->epub->ps.state, ESP_PM_ON);
		break;
	}
	case SIP_EVT_TXIDLE:{
		//struct sip_evt_txidle *txidle = (struct sip_evt_txidle *)(buf + SIP_CTRL_HDR_LEN);
		//sip_txdone_clear(sip, txidle->last_seq);
		break;
	}
#ifndef FAST_TX_STATUS
        case SIP_EVT_TX_STATUS: {
                struct sip_evt_tx_report *report = (struct sip_evt_tx_report *)(buf + SIP_CTRL_HDR_LEN);
                sip_txdoneq_process(sip, report);

                break;
        }
#endif /* FAST_TX_STATUS */

        case SIP_EVT_SCAN_RESULT: {
                struct sip_evt_scan_report *report = (struct sip_evt_scan_report *)(buf + SIP_CTRL_HDR_LEN);
                if (atomic_read(&sip->epub->wl.off)) {
                        esp_dbg(ESP_DBG_ERROR, "%s scan result while wlan off\n", __func__);
                        return 0;
                }
                sip_scandone_process(sip, report);

                break;
        }

		case SIP_EVT_ROC: {
                struct sip_evt_roc* report = (struct sip_evt_roc *)(buf + SIP_CTRL_HDR_LEN);
                esp_rocdone_process(sip->epub->hw, report);
                break;
        }


#ifdef ESP_RX_COPYBACK_TEST

        case SIP_EVT_COPYBACK: {
                u32 len = hdr->len - SIP_CTRL_HDR_LEN;

                esp_dbg(ESP_DBG_TRACE, "%s copyback len %d   seq %u\n", __func__, len, hdr->seq);

                memcpy(copyback_buf + copyback_offset, pkt->buf + SIP_CTRL_HDR_LEN, len);
                copyback_offset += len;

                //show_buf(pkt->buf, 256);

                //how about totlen % 256 == 0??
                if (hdr->hdr.len < 256) {
                        //sip_show_copyback_buf();
                        kfree(copyback_buf);
                }
        }
        break;
#endif /* ESP_RX_COPYBACK_TEST */
        case SIP_EVT_CREDIT_RPT:
                break;

#ifdef TEST_MODE
        case SIP_EVT_WAKEUP: {
                u8 check_str[12];
                struct sip_evt_wakeup* wakeup_evt=  (struct sip_evt_wakeup *)(buf + SIP_CTRL_HDR_LEN);
                sprintf((char *)&check_str, "%d", wakeup_evt->check_data);
                esp_test_cmd_event(TEST_CMD_WAKEUP, (char *)&check_str);
                break;
        }

        case SIP_EVT_DEBUG: {
                u8 check_str[100];
                int i;
                char * ptr_str = (char *)& check_str;
                struct sip_evt_debug* debug_evt =  (struct sip_evt_debug *)(buf + SIP_CTRL_HDR_LEN);
                for(i = 0; i < debug_evt->len; i++)
                        ptr_str += sprintf(ptr_str, "0x%x%s", debug_evt->results[i], i == debug_evt->len -1 ? "":" " );
                esp_test_cmd_event(TEST_CMD_DEBUG, (char *)&check_str);
                break;
        }

        case SIP_EVT_LOOPBACK: {
                u8 check_str[12];
                struct sip_evt_loopback *loopback_evt = (struct sip_evt_loopback *)(buf + SIP_CTRL_HDR_LEN);
                esp_dbg(ESP_DBG_LOG, "%s loopback len %d seq %u\n", __func__,hdr->len, hdr->seq);

                if(loopback_evt->pack_id!=get_loopback_id()) {
                        sprintf((char *)&check_str, "seq id error %d, expect %d", loopback_evt->pack_id, get_loopback_id());
                        esp_test_cmd_event(TEST_CMD_LOOPBACK, (char *)&check_str);
                }

                if((loopback_evt->pack_id+1) <get_loopback_num()) {
                        inc_loopback_id();
                        sip_send_loopback_mblk(sip, loopback_evt->txlen, loopback_evt->rxlen, get_loopback_id());
                } else {
                        sprintf((char *)&check_str, "test over!");
                        esp_test_cmd_event(TEST_CMD_LOOPBACK, (char *)&check_str);
                }
                break;
        }
#endif  /*TEST_MODE*/

        case SIP_EVT_SNPRINTF_TO_HOST: {
                u8 *p = (buf + sizeof(struct sip_hdr) + sizeof(u16));
                u16 *len = (u16 *)(buf + sizeof(struct sip_hdr));
		char test_res_str[560];
		sprintf(test_res_str, "esp_host:%llx\nesp_target: %.*s", DRIVER_VER, *len, p);
		
                esp_dbg(ESP_SHOW, "%s\n", test_res_str);
#ifdef ANDROID
		if(*len && sip->epub->sdio_state == ESP_SDIO_STATE_FIRST_INIT){
        		char filename[256];
			if (mod_eagle_path_get() == NULL)
        			sprintf(filename, "%s/%s", FWPATH, "test_results");
			else
        			sprintf(filename, "%s/%s", mod_eagle_path_get(), "test_results");
			android_readwrite_file(filename, NULL, test_res_str, strlen(test_res_str));
		}
#endif
                break;
        }
        case SIP_EVT_TRC_AMPDU: {
                struct sip_evt_trc_ampdu *ep = (struct sip_evt_trc_ampdu*)(buf + SIP_CTRL_HDR_LEN);
                struct esp_node *node = NULL;
                int i = 0;

                if (atomic_read(&sip->epub->wl.off)) {
                        esp_dbg(ESP_DBG_ERROR, "%s scan result while wlan off\n", __func__);
                        return 0;
                }
		
		node = esp_get_node_by_addr(sip->epub, ep->addr);
		if(node == NULL)
			break;
#if 0
                esp_tx_ba_session_op(sip, node, ep->state, ep->tid);
#else
                for (i = 0; i < 8; i++) {
                        if (ep->tid & (1<<i)) {
                                esp_tx_ba_session_op(sip, node, ep->state, i);
                        }
                }
#endif
                break;
        }

	    case SIP_EVT_EP: {
				 char *ep = (char *)(buf + SIP_CTRL_HDR_LEN);
				 static int counter = 0;
				 
				 esp_dbg(ESP_ATE, "%s EVT_EP \n\n", __func__);
				 if (counter++ < 2) {
					 esp_dbg(ESP_ATE, "ATE: %s \n", ep);
				 }

				 esp_test_ate_done_cb(ep);

				 break;
			 }
	case SIP_EVT_INIT_EP: {
				 char *ep = (char *)(buf + SIP_CTRL_HDR_LEN);
				 esp_dbg(ESP_ATE, "Phy Init: %s \n", ep);
				 break;
			      }

	case SIP_EVT_NOISEFLOOR:{
				        struct sip_evt_noisefloor *ep = (struct sip_evt_noisefloor *)(buf + SIP_CTRL_HDR_LEN);	                                      
					atomic_set(&sip->noise_floor, ep->noise_floor);
					break;
				}
        default:
                break;
        }

        return 0;
}
Ejemplo n.º 13
0
void android_ar6k_check_wow_status(AR_SOFTC_T *ar, struct sk_buff *skb, A_BOOL isEvent)
{
#ifdef CONFIG_HAS_WAKELOCK
    unsigned long wake_timeout = HZ; /* 1 second for normal window's ping test */
#endif
    AR_SOFTC_DEV_T *arPriv;
    A_UINT8  i; 
    A_BOOL needWake = FALSE;
    for(i = 0; i < num_device; i++) 
    {
        arPriv = ar->arDev[i];
        if (
#ifdef CONFIG_HAS_EARLYSUSPEND
            screen_is_off && 
#endif
                skb && arPriv->arConnected) {
            if (isEvent) {
                if (A_NETBUF_LEN(skb) >= sizeof(A_UINT16)) {
                    A_UINT16 cmd = *(const A_UINT16 *)A_NETBUF_DATA(skb);
                    switch (cmd) {
                    case WMI_CONNECT_EVENTID:
#ifdef CONFIG_HAS_WAKELOCK
                         wake_timeout = 3*HZ;
#endif
                         needWake = TRUE;
                         break;
                    default:
                        /* dont wake lock the system for other event */
                         break;
                    }
                }
            } else if (A_NETBUF_LEN(skb) >= sizeof(ATH_MAC_HDR)) {
                ATH_MAC_HDR *datap = (ATH_MAC_HDR *)A_NETBUF_DATA(skb);
                if (!IEEE80211_IS_MULTICAST(datap->dstMac)) {
                    switch (A_BE2CPU16(datap->typeOrLen)) {
                    case 0x0800: /* IP */
                        if (A_NETBUF_LEN(skb)>=24 &&
                            *((A_UCHAR*)A_NETBUF_DATA(skb)+23)==0x11) {
                            A_UCHAR *udpPkt = (A_UCHAR*)A_NETBUF_DATA(skb)+14;
                            A_UINT8 ihl = (*udpPkt & 0x0f) * sizeof(A_UINT32);
                            const A_UCHAR ipsec_keepalive[] = { 
                                0x11, 0x94, 0x11, 0x94, 0x00, 0x09, 0x00, 0x00, 0xff
                            };
                            udpPkt += ihl;
                            if (A_NETBUF_LEN(skb)>=14+ihl+sizeof(ipsec_keepalive) &&
                                    !memcmp(udpPkt, ipsec_keepalive, sizeof(ipsec_keepalive)-3) &&
                                    udpPkt[8]==0xff) {
                                /* 
                                 * RFC 3948 UDP Encapsulation of IPsec ESP Packets
                                 * Source and Destination port must be 4500
                                 * Receivers MUST NOT depend upon the UDP checksum being zero 
                                 * Sender must use 1 byte payload with 0xff
                                 * Receiver SHOULD ignore a received NAT-keepalive packet
                                 *
                                 * IPSec over UDP NAT keepalive packet. Just ignore
                                 */
                                break;
                            }
                        }
                    case 0x888e: /* EAPOL */
                    case 0x88c7: /* RSN_PREAUTH */
                    case 0x88b4: /* WAPI */
                         needWake = TRUE;
                         break;
                    case 0x0806: /* ARP is not important to hold wake lock */
                        needWake = (arPriv->arNetworkType==AP_NETWORK);
                        break;
                    default:
                         break;
                    }
                } else if ( !IEEE80211_IS_BROADCAST(datap->dstMac) ) {
                    if (A_NETBUF_LEN(skb)>=14+20 ) {
					    /* check if it is mDNS packets */
                        A_UINT8 *dstIpAddr = (A_UINT8*)(A_NETBUF_DATA(skb)+14+20-4);                    
                        struct net_device *ndev = arPriv->arNetDev;
                        needWake = ((dstIpAddr[3] & 0xf8) == 0xf8) &&
                                (arPriv->arNetworkType==AP_NETWORK || 
                                (ndev->flags & IFF_ALLMULTI || ndev->flags & IFF_MULTICAST));
                    }
                }else if (arPriv->arNetworkType==AP_NETWORK) {
                    switch (A_BE2CPU16(datap->typeOrLen)) {
                    case 0x0800: /* IP */
                        if (A_NETBUF_LEN(skb)>=14+20+2) {
                            A_UINT16 dstPort = *(A_UINT16*)(A_NETBUF_DATA(skb)+14+20);
                            dstPort = A_BE2CPU16(dstPort);
                            needWake = (dstPort == 0x43); /* dhcp request */
                        }
                        break;
                    case 0x0806: 
                        needWake = TRUE;
                    default:
                        break;
                    }
                }
             }
         }
    }
    if (needWake) {
#ifdef CONFIG_HAS_WAKELOCK
        /* keep host wake up if there is any event and packate comming in*/
        wake_lock_timeout(&ar6k_wow_wake_lock, wake_timeout);
#endif
        if (wowledon) {
            char buf[32];
            int len = sprintf(buf, "on");
            android_readwrite_file("/sys/power/state", NULL, buf, len);

            len = sprintf(buf, "%d", 127);
            android_readwrite_file("/sys/class/leds/lcd-backlight/brightness",
                                   NULL, buf,len);
        }
    }
}
Ejemplo n.º 14
0
void android_ar6k_check_wow_status(AR_SOFTC_T *ar, struct sk_buff *skb, A_BOOL isEvent)
{
    AR_SOFTC_DEV_T *arPriv;
    A_UINT8  i; 
    A_BOOL needWake = FALSE;
    for(i = 0; i < num_device; i++) 
    {
        arPriv = ar->arDev[i];
        if (
#ifdef CONFIG_HAS_EARLYSUSPEND
            screen_is_off && 
#endif
                skb && arPriv->arConnected) {
            if (isEvent) {
                if (A_NETBUF_LEN(skb) >= sizeof(A_UINT16)) {
                    A_UINT16 cmd = *(const A_UINT16 *)A_NETBUF_DATA(skb);
                    switch (cmd) {
                    case WMI_CONNECT_EVENTID:
                    case WMI_DISCONNECT_EVENTID:
                         needWake = TRUE;
                         break;
                    default:
                        /* dont wake lock the system for other event */
                         break;
                    }
                }
            } else if (A_NETBUF_LEN(skb) >= sizeof(ATH_MAC_HDR)) {
                ATH_MAC_HDR *datap = (ATH_MAC_HDR *)A_NETBUF_DATA(skb);
                if (!IEEE80211_IS_MULTICAST(datap->dstMac)) {
                    switch (A_BE2CPU16(datap->typeOrLen)) {
                    case 0x0800: /* IP */
                    case 0x888e: /* EAPOL */
                    case 0x88c7: /* RSN_PREAUTH */
                    case 0x88b4: /* WAPI */
                         needWake = TRUE;
                         break;
                    case 0x0806: /* ARP is not important to hold wake lock */
                        needWake = (arPriv->arNetworkType==AP_NETWORK);
                        break;
                    default:
                         break;
                    }
                } else if ( !IEEE80211_IS_BROADCAST(datap->dstMac) ) {
                    if (A_NETBUF_LEN(skb)>=14+20 ) {
					    /* check if it is mDNS packets */
                        A_UINT8 *dstIpAddr = (A_UINT8*)(A_NETBUF_DATA(skb)+14+20-4);                    
                        struct net_device *ndev = arPriv->arNetDev;
                        needWake = ((dstIpAddr[3] & 0xf8) == 0xf8) &&
                                (arPriv->arNetworkType==AP_NETWORK || 
                                (ndev->flags & IFF_ALLMULTI || ndev->flags & IFF_MULTICAST));
                    }
                }else if (arPriv->arNetworkType==AP_NETWORK) {
                    switch (A_BE2CPU16(datap->typeOrLen)) {
                    case 0x0800: /* IP */
                        if (A_NETBUF_LEN(skb)>=14+20+2) {
                            A_UINT16 dstPort = *(A_UINT16*)(A_NETBUF_DATA(skb)+14+20);
                            dstPort = A_BE2CPU16(dstPort);
                            needWake = (dstPort == 0x43); /* dhcp request */
                        }
                        break;
                    case 0x0806: 
                        needWake = TRUE;
                    default:
                        break;
                    }
                }
             }
         }
    }
    if (needWake) {
#ifdef CONFIG_HAS_WAKELOCK
        /* keep host wake up if there is any event and packate comming in*/
        wake_lock_timeout(&ar6k_wow_wake_lock, 3*HZ);
#endif
        if (wowledon) {
            char buf[32];
            int len = sprintf(buf, "on");
            android_readwrite_file("/sys/power/state", NULL, buf, len);

            len = sprintf(buf, "%d", 127);
            android_readwrite_file("/sys/class/leds/lcd-backlight/brightness",
                                   NULL, buf,len);
        }
    }
}
Ejemplo n.º 15
0
static int ath6kl_fetch_nvmac_info(struct ath6kl *ar)
{
	char softmac_temp[64];
	int ret = 0, ath6kl_softmac_len = 0;
	int isnvmac_imei = 0, isnvmac_wifi = 0;
	int isnvmac_file = 0, ismac_file = 0;

	char nvfilepath[32] = {0};
	char *nvfilepath_imei = "/efs/imei/.nvmac.info";
	char *nvfilepath_wifi = "/efs/wifi/.nvmac.info";
	char *softmac_filename = "/efs/wifi/.mac.info";
	char *softmac_old_filename = "/data/.mac.info";

	do {
		/*
		isnvmac_imei = android_readwrite_file(nvfilepath_imei,
								NULL, NULL, 0);
		isnvmac_wifi = android_readwrite_file(nvfilepath_wifi,
								NULL, NULL, 0); */
		ismac_file = android_readwrite_file(softmac_filename,
								NULL, NULL, 0);

		/*
		if (isnvmac_imei >= 16 && isnvmac_wifi >= 16) {
			strcpy(nvfilepath, nvfilepath_wifi);
			isnvmac_file = isnvmac_wifi;
		} else if (isnvmac_wifi >= 16) {
			strcpy(nvfilepath, nvfilepath_wifi);
			isnvmac_file = isnvmac_wifi;
		} else if (isnvmac_imei >= 16) {
			strcpy(nvfilepath, nvfilepath_imei);
			isnvmac_file = isnvmac_imei;
		} */

		/* copy .nvmac.info file to .mac.info
		   wifi driver will use .mac.info finally */
		/*
		if (isnvmac_file >= 16) {
			ret = android_readwrite_file(nvfilepath,
				(char *)softmac_temp, NULL, isnvmac_file);
			ath6kl_dbg(ATH6KL_DBG_BOOT,
				"%s: Read Mac Address on nvmac.info - %d\n",
				__func__, ret);
			ret = android_readwrite_file(softmac_filename,
				NULL, (char *)softmac_temp, ret);
			ath6kl_dbg(ATH6KL_DBG_BOOT,
				"%s: Write Mac Address on mac.info - %d\n",
				__func__, ret);
			ret = android_readwrite_file(softmac_old_filename,
				NULL, (char *)softmac_temp, ret);
		} */

		//if (isnvmac_file < 16 && ismac_file < 16) {
		if (ismac_file < 16) {
			snprintf(softmac_temp, sizeof(softmac_temp),
				"00:12:34:%02x:%02x:%02x",
				random32() & 0xff,
				random32() & 0xff,
				random32() & 0xff);

			ret = android_readwrite_file(softmac_filename, NULL,
				(char *)softmac_temp, strlen(softmac_temp));
			ath6kl_dbg(ATH6KL_DBG_BOOT,
				"%s: Write Random Mac on mac.info - %d\n",
				__func__, ret);
			ret = android_readwrite_file(softmac_old_filename, NULL,
				(char *)softmac_temp, strlen(softmac_temp));
		}


		ret = android_readwrite_file(softmac_filename, NULL, NULL, 0);
		if (ret < 0)
			break;
		else
			ath6kl_softmac_len = ret;

		ath6kl_softmac = vmalloc(ath6kl_softmac_len);
		if (!ath6kl_softmac) {
			ath6kl_dbg(ATH6KL_DBG_BOOT,
				"%s: Cannot allocate buffer for %s (%d)\n",
				__func__, softmac_filename, ath6kl_softmac_len);
			ret = -ENOMEM;
			break;
		}

		ret = android_readwrite_file(softmac_filename,
					(char *)ath6kl_softmac,
					NULL, ath6kl_softmac_len);

		if (ret != ath6kl_softmac_len) {
			ath6kl_dbg(ATH6KL_DBG_BOOT,
					"%s: file read error, length %d\n",
					__func__, ath6kl_softmac_len);
			vfree(ath6kl_softmac);
			ret = -1;
			break;
		}

		if (!strncmp(ath6kl_softmac, "00:00:00:00:00:00", 17)) {
			ath6kl_dbg(ATH6KL_DBG_BOOT, "%s: mac address is zero\n",
					 __func__);
			vfree(ath6kl_softmac);
			ret = -1;
			break;
		}

		ret = 0;
	} while (0);

	return ret;
}