Exemplo n.º 1
0
int
dhd_prot_init(dhd_pub_t *dhd)
{
	int ret = 0;
	char buf[128];

	DHD_TRACE(("%s: Enter\n", __FUNCTION__));

	dhd_os_proto_block(dhd);

	/* Get the device MAC address */
	strcpy(buf, "cur_etheraddr");
	ret = dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf));
	if (ret < 0) {
		goto fail;
	}
	memcpy(dhd->mac.octet, buf, ETHER_ADDR_LEN);

#ifdef EMBEDDED_PLATFORM
	ret = dhd_preinit_ioctls(dhd);
#endif /* EMBEDDED_PLATFORM */

	/* Always assumes wl for now */
	dhd->iswl = TRUE;

fail:
	dhd_os_proto_unblock(dhd);

	return ret;
}
Exemplo n.º 2
0
int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen)
{
#ifdef ARP_OFFLOAD_SUPPORT
       int retcode;
       int iov_len = 0;


       if (!buf)
               return -1;

       dhd_os_proto_block(dhd);

       iov_len = bcm_mkiovar("arp_hostip", 0, 0, buf, buflen);
       retcode = dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, buflen);

       dhd_os_proto_unblock(dhd);

       if (retcode) {
               DHD_TRACE(("%s: ioctl WLC_GET_VAR error %d\n",
               __FUNCTION__, retcode));

               return -1;
       }
#endif /* ARP_OFFLOAD_SUPPORT */
       return 0;
}
static int
dhd_es_unlock_dhd_bus(void)
{
/* LGE_CHANGE_S, [[email protected]], 2010-04-22, WBT Fix */
// WBT Fix TD# 36997
	void *bus;
	bus = dhd_es_get_dhd_pub();
	if ( bus )
		dhd_os_proto_unblock(bus);
/* LGE_CHANGE_S, [[email protected]], 2010-04-22, WBT Fix */
	return 0;
}
Exemplo n.º 4
0
int
dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len)
{
	int ret;

	dhd_os_proto_block(dhd_pub);

	ret = dhd_prot_ioctl(dhd_pub, ifindex, ioc, buf, len);


	dhd_os_proto_unblock(dhd_pub);
	return ret;
}
Exemplo n.º 5
0
	/* Writing Newly generated MAC ID to the Dongle */
	if (0 == _dhd_set_mac_address(dhd, 0, mac))
		DHD_INFO(("dhd_bus_start: MACID is overwritten\n"));
	else
		DHD_ERROR(("dhd_bus_start: _dhd_set_mac_address() failed\n"));
	
    return 0;
}

#endif /* READ_MACADDR */
#ifdef RDWR_MACADDR
static int g_iMacFlag;

enum {
	MACADDR_NONE =0 ,
		MACADDR_MOD,
		MACADDR_MOD_RANDOM,
		MACADDR_MOD_NONE,
		MACADDR_COB,
		MACADDR_COB_RANDOM
};

int WriteRDWR_Macaddr(struct ether_addr *mac)
{
	char* filepath			= "/data/.mac.info";
	struct file *fp_mac	= NULL;
	char buf[18]			= {0};
	mm_segment_t oldfs		= {0};
	int ret = -1;
	
	if ((g_iMacFlag != MACADDR_COB) && (g_iMacFlag != MACADDR_MOD))
		return 0;
	
	sprintf(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]);
	
	fp_mac = filp_open(filepath, O_RDWR | O_CREAT, 0666); // File is always created.
	if(IS_ERR(fp_mac)) {
		DHD_ERROR(("[WIFI] %s: File open error\n", filepath));
		return -1;
	}
	else {
		oldfs = get_fs();
		set_fs(get_ds());
		
		if(fp_mac->f_mode & FMODE_WRITE) {
			ret = fp_mac->f_op->write(fp_mac, (const char *)buf, sizeof(buf), &fp_mac->f_pos);
			if(ret < 0)
				DHD_ERROR(("[WIFI] Mac address [%s] Failed to write into File: %s\n", buf, filepath));
			else
				DHD_INFO(("[WIFI] Mac address [%s] written into File: %s\n", buf, filepath));
		}       
		set_fs(oldfs);
		filp_close(fp_mac, NULL);
	}
	
	return 0;
	
}

#if 0 /* disable because it's not used yet */
int ReadMacAddress_OTP(dhd_pub_t *dhdp, char cur_mac[])
{
	int ret = -1;
	
	dhd_os_proto_block(dhdp);
	strcpy(cur_mac, "cur_etheraddr");
	ret = dhdcdc_query_ioctl(dhdp, 0, WLC_GET_VAR, cur_mac, sizeof(cur_mac));
	if (ret < 0) {
		DHD_ERROR(("Current READ MAC error \r\n"));
		memset(cur_mac , 0 , ETHER_ADDR_LEN);
		return -1;
	}
	else {
		DHD_ERROR(("READ MAC (OTP) : [%02X][%02X][%02X][%02X][%02X][%02X] \r\n" , 
			cur_mac[0], cur_mac[1], cur_mac[2], cur_mac[3], cur_mac[4], cur_mac[5]));
	}
	dhd_os_proto_unblock(dhdp);
	
	return 0;
}
Exemplo n.º 6
0
void dhd_arp_offload_add_ip(dhd_pub_t *dhd, u32 ipaddr)
{
#ifdef ARP_OFFLOAD_SUPPORT
       int iov_len = 0;
       char iovbuf[32];
       int retcode;

       dhd_os_proto_block(dhd);

       iov_len = bcm_mkiovar("arp_hostip", (char *)&ipaddr, 4, iovbuf, sizeof(iovbuf));
       retcode = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len);

       dhd_os_proto_unblock(dhd);

       if (retcode)
               DHD_TRACE(("%s: ARP ip addr add failed, retcode = %d\n",
               __FUNCTION__, retcode));
       else
               DHD_TRACE(("%s: ARP ipaddr entry added\n",
               __FUNCTION__));
#endif /* ARP_OFFLOAD_SUPPORT */
}
Exemplo n.º 7
0
void dhd_arp_cleanup(dhd_pub_t *dhd)
{
#ifdef ARP_OFFLOAD_SUPPORT
       int ret = 0;
       int iov_len = 0;
       char iovbuf[128];

       if (dhd == NULL) return;

       dhd_os_proto_block(dhd);

       iov_len = bcm_mkiovar("arp_hostip_clear", 0, 0, iovbuf, sizeof(iovbuf));
       if ((ret  = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len)) < 0)
               DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret));

       iov_len = bcm_mkiovar("arp_table_clear", 0, 0, iovbuf, sizeof(iovbuf));
       if ((ret  = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len)) < 0)
               DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret));

       dhd_os_proto_unblock(dhd);

#endif /* ARP_OFFLOAD_SUPPORT */
}
Exemplo n.º 8
0
int
dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t * ioc, void * buf, int len)
{
	dhd_prot_t *prot = dhd->prot;
	int ret = -1;

	if (dhd->busstate == DHD_BUS_DOWN) {
		DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__));
		return ret;
	}
	dhd_os_proto_block(dhd);

	DHD_TRACE(("%s: Enter\n", __FUNCTION__));

	ASSERT(len <= WLC_IOCTL_MAXLEN);

	if (len > WLC_IOCTL_MAXLEN)
		goto done;

	if (prot->pending == TRUE) {
		DHD_TRACE(("CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n",
			ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd,
			(unsigned long)prot->lastcmd));
		if ((ioc->cmd == WLC_SET_VAR) || (ioc->cmd == WLC_GET_VAR)) {
			DHD_TRACE(("iovar cmd=%s\n", (char*)buf));
		}
		goto done;
	}

	prot->pending = TRUE;
	prot->lastcmd = ioc->cmd;
	if (ioc->set)
		ret = dhdcdc_set_ioctl(dhd, ifidx, ioc->cmd, buf, len);
	else {
		ret = dhdcdc_query_ioctl(dhd, ifidx, ioc->cmd, buf, len);
		if (ret > 0)
			ioc->used = ret - sizeof(cdc_ioctl_t);
	}

	/* Too many programs assume ioctl() returns 0 on success */
	if (ret >= 0)
		ret = 0;
	else {
		cdc_ioctl_t *msg = &prot->msg;
		ioc->needed = ltoh32(msg->len); /* len == needed when set/query fails from dongle */
	}

	/* Intercept the wme_dp ioctl here */
	if ((!ret) && (ioc->cmd == WLC_SET_VAR) && (!strcmp(buf, "wme_dp"))) {
		int slen, val = 0;

		slen = strlen("wme_dp") + 1;
		if (len >= (int)(slen + sizeof(int)))
			bcopy(((char *)buf + slen), &val, sizeof(int));
		dhd->wme_dp = (uint8) ltoh32(val);
	}

	prot->pending = FALSE;

done:
	dhd_os_proto_unblock(dhd);

	return ret;
}
Exemplo n.º 9
0
int dhd_preinit_ioctls(dhd_pub_t *dhd)
{
	char iovbuf[WL_EVENTING_MASK_LEN + 12];	/*  Room for
				 "event_msgs" + '\0' + bitvec  */
	uint up = 0;
	char buf[128], *ptr;
	uint power_mode = PM_FAST;
	u32 dongle_align = DHD_SDALIGN;
	u32 glom = 0;
	uint bcn_timeout = 3;
	int scan_assoc_time = 40;
	int scan_unassoc_time = 40;
#ifdef GET_CUSTOM_MAC_ENABLE
	int ret = 0;
	u8 ea_addr[ETH_ALEN];
#endif				/* GET_CUSTOM_MAC_ENABLE */

	dhd_os_proto_block(dhd);

#ifdef GET_CUSTOM_MAC_ENABLE
	/* Read MAC address from external customer place
	 ** NOTE that default mac address has to be present in
	 ** otp or nvram file to bring up
	 ** firmware but unique per board mac address maybe provided by
	 ** customer code
	 */
	ret = dhd_custom_get_mac_address(ea_addr);
	if (!ret) {
		bcm_mkiovar("cur_etheraddr", (void *)ea_addr, ETH_ALEN,
			    buf, sizeof(buf));
		ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
		if (ret < 0) {
			DHD_ERROR(("%s: can't set MAC address , error=%d\n",
				   __func__, ret));
		} else
			memcpy(dhd->mac.octet, (void *)&ea_addr,
			       ETH_ALEN);
	}
#endif				/* GET_CUSTOM_MAC_ENABLE */

	/* Set Country code */
	if (dhd->country_code[0] != 0) {
		if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_COUNTRY,
				     dhd->country_code,
				     sizeof(dhd->country_code)) < 0) {
			DHD_ERROR(("%s: country code setting failed\n",
				   __func__));
		}
	}

	/* query for 'ver' to get version info from firmware */
	memset(buf, 0, sizeof(buf));
	ptr = buf;
	bcm_mkiovar("ver", 0, 0, buf, sizeof(buf));
	dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf));
	strsep(&ptr, "\n");
	/* Print fw version info */
	DHD_ERROR(("Firmware version = %s\n", buf));

	/* Set PowerSave mode */
	dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode,
			 sizeof(power_mode));

	/* Match Host and Dongle rx alignment */
	bcm_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf,
		    sizeof(iovbuf));
	dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));

	/* disable glom option per default */
	bcm_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf));
	dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));

	/* Setup timeout if Beacons are lost and roam is off to report
		 link down */
	bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf,
		    sizeof(iovbuf));
	dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));

	/* Enable/Disable build-in roaming to allowed ext supplicant to take
		 of romaing */
	bcm_mkiovar("roam_off", (char *)&dhd_roam, 4, iovbuf, sizeof(iovbuf));
	dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));

	/* Force STA UP */
	if (dhd_radio_up)
		dhdcdc_set_ioctl(dhd, 0, WLC_UP, (char *)&up, sizeof(up));

	/* Setup event_msgs */
	bcm_mkiovar("event_msgs", dhd->eventmask, WL_EVENTING_MASK_LEN, iovbuf,
		    sizeof(iovbuf));
	dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));

	dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_CHANNEL_TIME,
			 (char *)&scan_assoc_time, sizeof(scan_assoc_time));
	dhdcdc_set_ioctl(dhd, 0, WLC_SET_SCAN_UNASSOC_TIME,
			 (char *)&scan_unassoc_time, sizeof(scan_unassoc_time));

#ifdef ARP_OFFLOAD_SUPPORT
	/* Set and enable ARP offload feature */
	if (dhd_arp_enable)
		dhd_arp_offload_set(dhd, dhd_arp_mode);
	dhd_arp_offload_enable(dhd, dhd_arp_enable);
#endif				/* ARP_OFFLOAD_SUPPORT */

#ifdef PKT_FILTER_SUPPORT
	{
		int i;
		/* Set up pkt filter */
		if (dhd_pkt_filter_enable) {
			for (i = 0; i < dhd->pktfilter_count; i++) {
				dhd_pktfilter_offload_set(dhd,
							  dhd->pktfilter[i]);
				dhd_pktfilter_offload_enable(dhd,
				     dhd->pktfilter[i],
				     dhd_pkt_filter_init,
				     dhd_master_mode);
			}
		}
	}
#endif				/* PKT_FILTER_SUPPORT */

	dhd_os_proto_unblock(dhd);

	return 0;
}