int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len) { dhd_prot_t *prot = dhd->prot; cdc_ioctl_t *msg = &prot->msg; int ret = 0; uint32 flags, id; DHD_TRACE(("%s: Enter\n", __FUNCTION__)); DHD_CTL(("%s: cmd %d len %d\n", __FUNCTION__, cmd, len)); if (prot == 0) { DHD_ERROR(("dhdcdc_set_ioctl: dhd->prot NULL. idx=%d, cmd=0x%x", ifidx, cmd)); goto done; } memset(msg, 0, sizeof(cdc_ioctl_t)); msg->cmd = htol32(cmd); msg->len = htol32(len); msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT) | CDCF_IOC_SET; CDC_SET_IF_IDX(msg, ifidx); msg->flags |= htol32(msg->flags); if (buf) memcpy(prot->buf, buf, len); if ((ret = dhdcdc_msg(dhd)) < 0) goto done; if ((ret = dhdcdc_cmplt(dhd, prot->reqid, len)) < 0) goto done; flags = ltoh32(msg->flags); id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT; if (id != prot->reqid) { DHD_ERROR(("%s: %s: unexpected request id %d (expected %d)\n", dhd_ifname(dhd, ifidx), __FUNCTION__, id, prot->reqid)); ret = -EINVAL; goto done; } /* Check the ERROR flag */ if (flags & CDCF_IOC_ERROR) { ret = ltoh32(msg->status); /* Cache error from dongle */ dhd->dongle_error = ret; } done: return ret; }
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; }
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; }
int dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len) { dhd_prot_t *prot = dhd->prot; cdc_ioctl_t *msg = &prot->msg; void *info; int ret = 0, retries = 0; uint32 id, flags = 0; DHD_TRACE(("%s: Enter\n", __FUNCTION__)); DHD_CTL(("%s: cmd %d len %d\n", __FUNCTION__, cmd, len)); /* Respond "bcmerror" and "bcmerrorstr" with local cache */ if (cmd == WLC_GET_VAR && buf) { if (!strcmp((char *)buf, "bcmerrorstr")) { strncpy((char *)buf, bcmerrorstr(dhd->dongle_error), BCME_STRLEN); goto done; } else if (!strcmp((char *)buf, "bcmerror")) { *(int *)buf = dhd->dongle_error; goto done; } } memset(msg, 0, sizeof(cdc_ioctl_t)); msg->cmd = htol32(cmd); msg->len = htol32(len); msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT); CDC_SET_IF_IDX(msg, ifidx); msg->flags = htol32(msg->flags); if (buf) memcpy(prot->buf, buf, len); if ((ret = dhdcdc_msg(dhd)) < 0) { DHD_ERROR(("dhdcdc_query_ioctl: dhdcdc_msg failed w/status %d\n", ret)); goto done; } retry: /* wait for interrupt and get first fragment */ if ((ret = dhdcdc_cmplt(dhd, prot->reqid, len)) < 0) goto done; flags = ltoh32(msg->flags); id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT; if ((id < prot->reqid) && (++retries < RETRIES)) goto retry; if (id != prot->reqid) { DHD_ERROR(("%s: %s: unexpected request id %d (expected %d)\n", dhd_ifname(dhd, ifidx), __FUNCTION__, id, prot->reqid)); ret = -EINVAL; goto done; } /* Check info buffer */ info = (void*)&msg[1]; /* Copy info buffer */ if (buf) { if (ret < (int)len) len = ret; memcpy(buf, info, len); } /* Check the ERROR flag */ if (flags & CDCF_IOC_ERROR) { ret = ltoh32(msg->status); /* Cache error from dongle */ dhd->dongle_error = ret; } done: return ret; }