Пример #1
0
static int
dbus_iovar_process(usb_info_t* usbinfo, const char *name,
                   void *params, int plen, void *arg, int len, bool set)
{
    const bcm_iovar_t *vi = NULL;
    int bcmerror = 0;
    int val_size;
    uint32 actionid;

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

    ASSERT(name);
    ASSERT(len >= 0);

    /* Get MUST have return space */
    ASSERT(set || (arg && len));

    /* Set does NOT take qualifiers */
    ASSERT(!set || (!params && !plen));

    /* Look up var locally; if not found pass to host driver */
    if ((vi = bcm_iovar_lookup(dhdusb_iovars, name)) == NULL) {
        /* Not Supported */
        bcmerror = BCME_UNSUPPORTED;
        DBUSTRACE(("%s: IOVAR %s is not supported\n", name, __FUNCTION__));
        goto exit;

    }

    DBUSTRACE(("%s: %s %s, len %d plen %d\n", __FUNCTION__,
               name, (set ? "set" : "get"), len, plen));

    /* set up 'params' pointer in case this is a set command so that
     * the convenience int and bool code can be common to set and get
     */
    if (params == NULL) {
        params = arg;
        plen = len;
    }

    if (vi->type == IOVT_VOID)
        val_size = 0;
    else if (vi->type == IOVT_BUFFER)
        val_size = len;
    else
        /* all other types are integer sized */
        val_size = sizeof(int);

    actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid);
    bcmerror = dbus_usb_doiovar(usbinfo, vi, actionid,
                                name, params, plen, arg, len, val_size);

exit:
    return bcmerror;
}
Пример #2
0
static int
brcmf_c_iovar_op(struct brcmf_pub *drvr, const char *name,
	     void *params, int plen, void *arg, int len, bool set)
{
	int bcmerror = 0;
	int val_size;
	const struct brcmu_iovar *vi = NULL;
	u32 actionid;

	BRCMF_TRACE(("%s: Enter\n", __func__));

	if (name == NULL || len <= 0)
		return -EINVAL;

	/* Set does not take qualifiers */
	if (set && (params || plen))
		return -EINVAL;

	/* Get must have return space;*/
	if (!set && !(arg && len))
		return -EINVAL;

	vi = brcmu_iovar_lookup(brcmf_iovars, name);
	if (vi == NULL) {
		bcmerror = -ENOTSUPP;
		goto exit;
	}

	BRCMF_CTL(("%s: %s %s, len %d plen %d\n", __func__,
		   name, (set ? "set" : "get"), len, plen));

	/* set up 'params' pointer in case this is a set command so that
	 * the convenience int and bool code can be common to set and get
	 */
	if (params == NULL) {
		params = arg;
		plen = len;
	}

	if (vi->type == IOVT_VOID)
		val_size = 0;
	else if (vi->type == IOVT_BUFFER)
		val_size = len;
	else
		/* all other types are integer sized */
		val_size = sizeof(int);

	actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid);
	bcmerror =
	    brcmf_c_doiovar(drvr, vi, actionid, name, params, plen, arg, len,
			val_size);

exit:
	return bcmerror;
}
Пример #3
0
static int
dhd_iovar_op(dhd_pub_t *dhd_pub, const char *name,
	     void *params, int plen, void *arg, int len, bool set)
{
	int bcmerror = 0;
	int val_size;
	const bcm_iovar_t *vi = NULL;
	u32 actionid;

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

	ASSERT(name);
	ASSERT(len >= 0);

	/* Get MUST have return space */
	ASSERT(set || (arg && len));

	/* Set does NOT take qualifiers */
	ASSERT(!set || (!params && !plen));

	vi = bcm_iovar_lookup(dhd_iovars, name);
	if (vi == NULL) {
		bcmerror = -ENOTSUPP;
		goto exit;
	}

	DHD_CTL(("%s: %s %s, len %d plen %d\n", __func__,
		 name, (set ? "set" : "get"), len, plen));

	/* set up 'params' pointer in case this is a set command so that
	 * the convenience int and bool code can be common to set and get
	 */
	if (params == NULL) {
		params = arg;
		plen = len;
	}

	if (vi->type == IOVT_VOID)
		val_size = 0;
	else if (vi->type == IOVT_BUFFER)
		val_size = len;
	else
		/* all other types are integer sized */
		val_size = sizeof(int);

	actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid);
	bcmerror =
	    dhd_doiovar(dhd_pub, vi, actionid, name, params, plen, arg, len,
			val_size);

exit:
	return bcmerror;
}
Пример #4
0
static int
dhd_iovar_op(dhd_pub_t *dhd_pub, const char *name,
             void *params, int plen, void *arg, int len, bool set)
{
	int bcmerror = 0;
	int val_size;
	const bcm_iovar_t *vi = NULL;
	uint32 actionid;

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

	ASSERT(name);
	ASSERT(len >= 0);

	
	ASSERT(set || (arg && len));

	
	ASSERT(!set || (!params && !plen));

	if ((vi = bcm_iovar_lookup(dhd_iovars, name)) == NULL)
	{
		bcmerror = BCME_UNSUPPORTED;
		goto exit;
	}

	DHD_CTL(("%s: %s %s, len %d plen %d\n", __FUNCTION__,
	         name, (set ? "set" : "get"), len, plen));

	
	if (params == NULL) {
		params = arg;
		plen = len;
	}

	if (vi->type == IOVT_VOID)
		val_size = 0;
	else if (vi->type == IOVT_BUFFER)
		val_size = len;
	else
		
		val_size = sizeof(int);

	actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid);
	bcmerror = dhd_doiovar(dhd_pub, vi, actionid, name, params, plen, arg, len, val_size);

exit:
	return bcmerror;
}
Пример #5
0
static int
brcmf_c_doiovar(struct brcmf_pub *drvr, const struct brcmu_iovar *vi,
		u32 actionid, const char *name, void *params, int plen,
		void *arg, int len, int val_size)
{
	int bcmerror = 0;
	s32 int_val = 0;

	BRCMF_TRACE(("%s: Enter\n", __func__));

	bcmerror = brcmu_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid));
	if (bcmerror != 0)
		goto exit;

	if (plen >= (int)sizeof(int_val))
		memcpy(&int_val, params, sizeof(int_val));

	switch (actionid) {
	case IOV_GVAL(IOV_VERSION):
		/* Need to have checked buffer length */
		strncpy((char *)arg, brcmf_version, len);
		break;

	case IOV_GVAL(IOV_MSGLEVEL):
		int_val = (s32) brcmf_msg_level;
		memcpy(arg, &int_val, val_size);
		break;

	case IOV_SVAL(IOV_MSGLEVEL):
		brcmf_msg_level = int_val;
		break;

	case IOV_GVAL(IOV_BCMERRORSTR):
		strncpy((char *)arg, "bcm_error",
			BCME_STRLEN);
		((char *)arg)[BCME_STRLEN - 1] = 0x00;
		break;

	case IOV_GVAL(IOV_BCMERROR):
		int_val = (s32) drvr->bcmerror;
		memcpy(arg, &int_val, val_size);
		break;

	case IOV_GVAL(IOV_DUMP):
		bcmerror = brcmf_c_dump(drvr, arg, len);
		break;

	case IOV_SVAL(IOV_CLEARCOUNTS):
		drvr->tx_packets = drvr->rx_packets = 0;
		drvr->tx_errors = drvr->rx_errors = 0;
		drvr->tx_ctlpkts = drvr->rx_ctlpkts = 0;
		drvr->tx_ctlerrs = drvr->rx_ctlerrs = 0;
		drvr->rx_dropped = 0;
		drvr->rx_readahead_cnt = 0;
		drvr->tx_realloc = 0;
		drvr->wd_dpc_sched = 0;
		memset(&drvr->dstats, 0, sizeof(drvr->dstats));
		brcmf_bus_clearcounts(drvr);
		break;

	case IOV_GVAL(IOV_IOCTLTIMEOUT):{
			int_val = (s32) brcmf_os_get_ioctl_resp_timeout();
			memcpy(arg, &int_val, sizeof(int_val));
			break;
		}

	case IOV_SVAL(IOV_IOCTLTIMEOUT):{
			if (int_val <= 0)
				bcmerror = -EINVAL;
			else
				brcmf_os_set_ioctl_resp_timeout((unsigned int)
							      int_val);
			break;
		}

	default:
		bcmerror = -ENOTSUPP;
		break;
	}

exit:
	return bcmerror;
}
Пример #6
0
static int
dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, uint32 actionid,
	const char *name, void *params, int plen, void *arg, int len, int val_size)
{
	int bcmerror = 0;
	int32 int_val = 0;

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

	if ((bcmerror = bcm_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid))) != 0)
		goto exit;

	if (plen >= (int)sizeof(int_val))
		bcopy(params, &int_val, sizeof(int_val));

	switch (actionid) {
	case IOV_GVAL(IOV_VERSION):
		/* Need to have checked buffer length */
		strncpy((char*)arg, dhd_version, len);
		break;

	case IOV_GVAL(IOV_MSGLEVEL):
		int_val = (int32)dhd_msg_level;
		bcopy(&int_val, arg, val_size);
		break;

	case IOV_SVAL(IOV_MSGLEVEL):
		dhd_msg_level = int_val;
		break;

	case IOV_GVAL(IOV_BCMERRORSTR):
		strncpy((char *)arg, bcmerrorstr(dhd_pub->bcmerror), BCME_STRLEN);
		((char *)arg)[BCME_STRLEN - 1] = 0x00;
		break;

	case IOV_GVAL(IOV_BCMERROR):
		int_val = (int32)dhd_pub->bcmerror;
		bcopy(&int_val, arg, val_size);
		break;

	case IOV_GVAL(IOV_WDTICK):
		int_val = (int32)dhd_watchdog_ms;
		bcopy(&int_val, arg, val_size);
		break;

	case IOV_SVAL(IOV_WDTICK):
		if (!dhd_pub->up) {
			bcmerror = BCME_NOTUP;
			break;
		}
		dhd_os_wd_timer(dhd_pub, (uint)int_val);
		break;

	case IOV_GVAL(IOV_DUMP):
		bcmerror = dhd_dump(dhd_pub, arg, len);
		break;

	case IOV_SVAL(IOV_CLEARCOUNTS):
		dhd_pub->tx_packets = dhd_pub->rx_packets = 0;
		dhd_pub->tx_errors = dhd_pub->rx_errors = 0;
		dhd_pub->tx_ctlpkts = dhd_pub->rx_ctlpkts = 0;
		dhd_pub->tx_ctlerrs = dhd_pub->rx_ctlerrs = 0;
		dhd_pub->rx_dropped = 0;
		dhd_pub->rx_readahead_cnt = 0;
		dhd_pub->tx_realloc = 0;
		dhd_pub->rx_flushed = 0;
		memset(&dhd_pub->dstats, 0, sizeof(dhd_pub->dstats));
		dhd_bus_clearcounts(dhd_pub);
		break;


	case IOV_GVAL(IOV_IOCTLTIMEOUT):
	{
		int_val = (int32)dhd_os_get_ioctl_resp_timeout();
		bcopy(&int_val, arg, sizeof(int_val));
		break;
	}

	case IOV_SVAL(IOV_IOCTLTIMEOUT):
	{
		if (int_val <= 0)
			bcmerror = BCME_BADARG;
		else
			dhd_os_set_ioctl_resp_timeout((unsigned int)int_val);
		break;
	}


	default:
		bcmerror = BCME_UNSUPPORTED;
		break;
	}

exit:
	return bcmerror;
}
Пример #7
0
static int
dbus_usb_doiovar(usb_info_t *bus, const bcm_iovar_t *vi, uint32 actionid, const char *name,
                 void *params, int plen, void *arg, int len, int val_size)
{
    int bcmerror = 0;
    int32 int_val = 0;
    bool bool_val = 0;

    DBUSTRACE(("%s: Enter, action %d name %s params %p plen %d arg %p len %d val_size %d\n",
               __FUNCTION__, actionid, name, params, plen, arg, len, val_size));

    if ((bcmerror = bcm_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid))) != 0)
        goto exit;

    if (plen >= (int)sizeof(int_val))
        bcopy(params, &int_val, sizeof(int_val));

    bool_val = (int_val != 0) ? TRUE : FALSE;

    switch (actionid) {

    case IOV_SVAL(IOV_MEMBYTES):
    case IOV_GVAL(IOV_MEMBYTES):
    {
        uint32 address;
        uint size, dsize;
        uint8 *data;

        bool set = (actionid == IOV_SVAL(IOV_MEMBYTES));

        ASSERT(plen >= 2*sizeof(int));

        address = (uint32)int_val;
        bcopy((char *)params + sizeof(int_val), &int_val, sizeof(int_val));
        size = (uint)int_val;

        /* Do some validation */
        dsize = set ? plen - (2 * sizeof(int)) : len;
        if (dsize < size) {
            DBUSTRACE(("%s: error on %s membytes, addr 0x%08x size %d dsize %d\n",
                       __FUNCTION__, (set ? "set" : "get"), address, size, dsize));
            bcmerror = BCME_BADARG;
            break;
        }
        DBUSTRACE(("%s: Request to %s %d bytes at address 0x%08x\n", __FUNCTION__,
                   (set ? "write" : "read"), size, address));

        /* Generate the actual data pointer */
        data = set ? (uint8*)params + 2 * sizeof(int): (uint8*)arg;

        /* Call to do the transfer */
        bcmerror = dbus_usb_dl_writeimage(BUS_INFO(bus, usb_info_t), data, size);
    }
    break;


    case IOV_SVAL(IOV_SET_DOWNLOAD_STATE):

        if (bool_val == TRUE) {
            bcmerror = dbus_usb_dlneeded(bus);
            dbus_usb_rdl_dwnld_state(BUS_INFO(bus, usb_info_t));
        } else {
            usb_info_t *usbinfo = BUS_INFO(bus, usb_info_t);
            bcmerror = dbus_usb_dlrun(bus);
            usbinfo->pub->busstate = DBUS_STATE_DL_DONE;
        }
        break;

    case IOV_GVAL(IOV_HSIC_SLEEP):
        bool_val = dbus_usb_sleep_resume_state(BUS_INFO(bus, usb_info_t));
        bcopy(&bool_val, arg, val_size);
        break;

    case IOV_SVAL(IOV_HSIC_SLEEP):
        bcmerror = dbus_usb_sleep(BUS_INFO(bus, usb_info_t), bool_val);
        break;

    case IOV_GVAL(IOV_HSIC_AUTOSLEEP):
        bool_val = dbus_usb_autosleep_state(BUS_INFO(bus, usb_info_t));
        bcopy(&bool_val, arg, val_size);
        break;

    case IOV_SVAL(IOV_HSIC_AUTOSLEEP):
        bcmerror = dbus_usb_autosleep(BUS_INFO(bus, usb_info_t), bool_val);
        break;

    case IOV_SVAL(IOV_VARS):
        bcmerror = dhdusb_downloadvars(BUS_INFO(bus, usb_info_t), arg, len);
        break;

    default:
        bcmerror = BCME_UNSUPPORTED;
        break;
    }

exit:
    return bcmerror;
}
Пример #8
0
static int
dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, uint32 actionid, const char *name,
            void *params, int plen, void *arg, int len, int val_size)
{
	int bcmerror = 0;
	int32 int_val = 0;

	DHD_TRACE(("%s: Enter\n", __FUNCTION__));
	DHD_TRACE(("%s: actionid = %d; name %s\n", __FUNCTION__, actionid, name));

	if ((bcmerror = bcm_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid))) != 0)
		goto exit;

	if (plen >= (int)sizeof(int_val))
		bcopy(params, &int_val, sizeof(int_val));

	switch (actionid) {
	case IOV_GVAL(IOV_VERSION):
		/* Need to have checked buffer length */
		strncpy((char*)arg, dhd_version, len);
		break;

	case IOV_GVAL(IOV_MSGLEVEL):
		int_val = (int32)dhd_msg_level;
		bcopy(&int_val, arg, val_size);
		break;

	case IOV_SVAL(IOV_MSGLEVEL):
		dhd_msg_level = int_val;
		break;
	case IOV_GVAL(IOV_BCMERRORSTR):
		strncpy((char *)arg, bcmerrorstr(dhd_pub->bcmerror), BCME_STRLEN);
		((char *)arg)[BCME_STRLEN - 1] = 0x00;
		break;

	case IOV_GVAL(IOV_BCMERROR):
		int_val = (int32)dhd_pub->bcmerror;
		bcopy(&int_val, arg, val_size);
		break;

	case IOV_GVAL(IOV_WDTICK):
		int_val = (int32)dhd_watchdog_ms;
		bcopy(&int_val, arg, val_size);
		break;

	case IOV_SVAL(IOV_WDTICK):
		if (!dhd_pub->up) {
			bcmerror = BCME_NOTUP;
			break;
		}
		dhd_os_wd_timer(dhd_pub, (uint)int_val);
		break;

	case IOV_GVAL(IOV_DUMP):
		bcmerror = dhd_dump(dhd_pub, arg, len);
		break;

#ifdef DHD_DEBUG
	case IOV_GVAL(IOV_DCONSOLE_POLL):
		int_val = (int32)dhd_console_ms;
		bcopy(&int_val, arg, val_size);
		break;

	case IOV_SVAL(IOV_DCONSOLE_POLL):
		dhd_console_ms = (uint)int_val;
		break;

	case IOV_SVAL(IOV_CONS):
		if (len > 0)
			bcmerror = dhd_bus_console_in(dhd_pub, arg, len - 1);
		break;
#endif /* DHD_DEBUG */

	case IOV_SVAL(IOV_CLEARCOUNTS):
		dhd_pub->tx_packets = dhd_pub->rx_packets = 0;
		dhd_pub->tx_errors = dhd_pub->rx_errors = 0;
		dhd_pub->tx_ctlpkts = dhd_pub->rx_ctlpkts = 0;
		dhd_pub->tx_ctlerrs = dhd_pub->rx_ctlerrs = 0;
		dhd_pub->rx_dropped = 0;
		dhd_pub->rx_readahead_cnt = 0;
		dhd_pub->tx_realloc = 0;
		dhd_pub->wd_dpc_sched = 0;
		memset(&dhd_pub->dstats, 0, sizeof(dhd_pub->dstats));
		dhd_bus_clearcounts(dhd_pub);
		break;


	case IOV_GVAL(IOV_IOCTLTIMEOUT): {
		int_val = (int32)dhd_os_get_ioctl_resp_timeout();
		bcopy(&int_val, arg, sizeof(int_val));
		break;
	}

	case IOV_SVAL(IOV_IOCTLTIMEOUT): {
		if (int_val <= 0)
			bcmerror = BCME_BADARG;
		else
			dhd_os_set_ioctl_resp_timeout((unsigned int)int_val);
		break;
	}



	case IOV_GVAL(IOV_BUS_TYPE):
	/* The dhd application query the driver to check if its usb or sdio.  */
#ifdef BCMDHDUSB
		int_val = BUS_TYPE_USB;
#endif
		int_val = BUS_TYPE_SDIO;
		bcopy(&int_val, arg, val_size);
		break;


#ifdef WLMEDIA_HTSF
	case IOV_GVAL(IOV_WLPKTDLYSTAT_SZ):
		int_val = dhd_pub->htsfdlystat_sz;
		bcopy(&int_val, arg, val_size);
		break;

	case IOV_SVAL(IOV_WLPKTDLYSTAT_SZ):
		dhd_pub->htsfdlystat_sz = int_val & 0xff;
		printf("Setting tsfdlystat_sz:%d\n", dhd_pub->htsfdlystat_sz);
		break;
#endif
	case IOV_SVAL(IOV_CHANGEMTU):
		int_val &= 0xffff;
		bcmerror = dhd_change_mtu(dhd_pub, int_val, 0);
		break;

	default:
		bcmerror = BCME_UNSUPPORTED;
		break;
	}

exit:
	DHD_TRACE(("%s: actionid %d, bcmerror %d\n", __FUNCTION__, actionid, bcmerror));
	return bcmerror;
}
Пример #9
0
static int
dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid,
	    const char *name, void *params, int plen, void *arg, int len,
	    int val_size)
{
	int bcmerror = 0;
	s32 int_val = 0;

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

	bcmerror = bcm_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid));
	if (bcmerror != 0)
		goto exit;

	if (plen >= (int)sizeof(int_val))
		memcpy(&int_val, params, sizeof(int_val));

	switch (actionid) {
	case IOV_GVAL(IOV_VERSION):
		/* Need to have checked buffer length */
		strncpy((char *)arg, dhd_version, len);
		break;

	case IOV_GVAL(IOV_MSGLEVEL):
		int_val = (s32) dhd_msg_level;
		memcpy(arg, &int_val, val_size);
		break;

	case IOV_SVAL(IOV_MSGLEVEL):
		dhd_msg_level = int_val;
		break;

	case IOV_GVAL(IOV_BCMERRORSTR):
		strncpy((char *)arg, "bcm_error",
			BCME_STRLEN);
		((char *)arg)[BCME_STRLEN - 1] = 0x00;
		break;

	case IOV_GVAL(IOV_BCMERROR):
		int_val = (s32) dhd_pub->bcmerror;
		memcpy(arg, &int_val, val_size);
		break;

	case IOV_GVAL(IOV_WDTICK):
		int_val = (s32) dhd_watchdog_ms;
		memcpy(arg, &int_val, val_size);
		break;

	case IOV_SVAL(IOV_WDTICK):
		if (!dhd_pub->up) {
			bcmerror = -ENOLINK;
			break;
		}
		dhd_os_wd_timer(dhd_pub, (uint) int_val);
		break;

	case IOV_GVAL(IOV_DUMP):
		bcmerror = dhd_dump(dhd_pub, arg, len);
		break;

#ifdef DHD_DEBUG
	case IOV_GVAL(IOV_DCONSOLE_POLL):
		int_val = (s32) dhd_console_ms;
		memcpy(arg, &int_val, val_size);
		break;

	case IOV_SVAL(IOV_DCONSOLE_POLL):
		dhd_console_ms = (uint) int_val;
		break;

	case IOV_SVAL(IOV_CONS):
		if (len > 0)
			bcmerror = dhd_bus_console_in(dhd_pub, arg, len - 1);
		break;
#endif

	case IOV_SVAL(IOV_CLEARCOUNTS):
		dhd_pub->tx_packets = dhd_pub->rx_packets = 0;
		dhd_pub->tx_errors = dhd_pub->rx_errors = 0;
		dhd_pub->tx_ctlpkts = dhd_pub->rx_ctlpkts = 0;
		dhd_pub->tx_ctlerrs = dhd_pub->rx_ctlerrs = 0;
		dhd_pub->rx_dropped = 0;
		dhd_pub->rx_readahead_cnt = 0;
		dhd_pub->tx_realloc = 0;
		dhd_pub->wd_dpc_sched = 0;
		memset(&dhd_pub->dstats, 0, sizeof(dhd_pub->dstats));
		dhd_bus_clearcounts(dhd_pub);
		break;

	case IOV_GVAL(IOV_IOCTLTIMEOUT):{
			int_val = (s32) dhd_os_get_ioctl_resp_timeout();
			memcpy(arg, &int_val, sizeof(int_val));
			break;
		}

	case IOV_SVAL(IOV_IOCTLTIMEOUT):{
			if (int_val <= 0)
				bcmerror = -EINVAL;
			else
				dhd_os_set_ioctl_resp_timeout((unsigned int)
							      int_val);
			break;
		}

	default:
		bcmerror = -ENOTSUPP;
		break;
	}

exit:
	return bcmerror;
}