software/drivers/sd8887/src/wlan/mlinux/moal_priv.c
/**
 * @brief Set/Get TX data rate
 *
 * @param priv      A pointer to moal_private structure
 * @param wrq       A pointer to iwreq structure
 *
 * @return          0 --success, otherwise fail
 */
@brief Set/Get TX data rate
@param priv      A pointer to moal_private structure
@param wrq       A pointer to iwreq structure

@return          0 --success, otherwise fail
@brief Set / Get TX data rate @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_set_get_txrate(moal_private *priv, struct iwreq *wrq)
{
	int ret = 0;
	mlan_ds_rate *rate = NULL;
	mlan_ioctl_req *req = NULL;
	int rateindex = 0;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	if (wrq->u.data.length) {
		if (copy_from_user
		    (&rateindex, wrq->u.data.pointer, sizeof(int))) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		}
	}
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_rate));
	if (req == NULL) {
		ret = -ENOMEM;
		goto done;
	}
	rate = (mlan_ds_rate *)req->pbuf;
	rate->param.rate_cfg.rate_type = MLAN_RATE_INDEX;
	rate->sub_command = MLAN_OID_RATE_CFG;
	req->req_id = MLAN_IOCTL_RATE;
	if (!wrq->u.data.length)
		req->action = MLAN_ACT_GET;
	else {
		req->action = MLAN_ACT_SET;
		if (rateindex == AUTO_RATE)
			rate->param.rate_cfg.is_rate_auto = 1;
		else {
			if ((rateindex != MLAN_RATE_INDEX_MCS32) &&
			    ((rateindex < 0) ||
			     (rateindex > MLAN_RATE_INDEX_MCS7))) {
				ret = -EINVAL;
				goto done;
			}
		}
		rate->param.rate_cfg.rate = rateindex;
	}
	status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	} else {
		if (wrq->u.data.length)
			priv->rate_index = rateindex;
	}
	if (!wrq->u.data.length) {
		if (rate->param.rate_cfg.is_rate_auto)
			rateindex = AUTO_RATE;
		else
			rateindex = rate->param.rate_cfg.rate;
		wrq->u.data.length = 1;
		if (copy_to_user(wrq->u.data.pointer, &rateindex, sizeof(int)))
			ret = -EFAULT;
	}
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_set_get_txrate ( moal_private * priv , struct iwreq * wrq ) { int ret = 0 ; mlan_ds_rate * rate = NULL ; mlan_ioctl_req * req = NULL ; int rateindex = 0 ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; if ( wrq -> u . data . length ) { if ( copy_from_user ( & rateindex , wrq -> u . data . pointer , sizeof ( int ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } } req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_rate ) ) ; if ( req == NULL ) { ret = - ENOMEM ; goto done ; } rate = ( mlan_ds_rate * ) req -> pbuf ; rate -> param . rate_cfg . rate_type = MLAN_RATE_INDEX ; rate -> sub_command = MLAN_OID_RATE_CFG ; req -> req_id = MLAN_IOCTL_RATE ; if ( ! wrq -> u . data . length ) req -> action = MLAN_ACT_GET ; else { req -> action = MLAN_ACT_SET ; if ( rateindex == AUTO_RATE ) rate -> param . rate_cfg . is_rate_auto = 1 ; else { if ( ( rateindex != MLAN_RATE_INDEX_MCS32 ) && ( ( rateindex < 0 ) || ( rateindex > MLAN_RATE_INDEX_MCS7 ) ) ) { ret = - EINVAL ; goto done ; } } rate -> param . rate_cfg . rate = rateindex ; } status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } else { if ( wrq -> u . data . length ) priv -> rate_index = rateindex ; } if ( ! wrq -> u . data . length ) { if ( rate -> param . rate_cfg . is_rate_auto ) rateindex = AUTO_RATE ; else rateindex = rate -> param . rate_cfg . rate ; wrq -> u . data . length = 1 ; if ( copy_to_user ( wrq -> u . data . pointer , & rateindex , sizeof ( int ) ) ) ret = - EFAULT ; } done : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Set/Get TX data rate
 @param priv      A pointer to moal_private structure
 @param wrq       A pointer to iwreq structure
@brief Set / Get TX data rate @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure