software/drivers/sd8887/src/wlan/mlinux/moal_priv.c
/**
 *  @brief Set/Get add BA parameters
 *
 *  @param priv     Pointer to the moal_private driver data struct
 *  @param wrq      A pointer to iwreq structure
 *
 *  @return         0 --success, otherwise fail
 */
@brief Set/Get add BA parameters
@param priv     Pointer to the moal_private driver data struct
@param wrq      A pointer to iwreq structure

@return         0 --success, otherwise fail
@brief Set / Get add BA parameters @param priv Pointer to the moal_private driver data struct @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_addba_para_updt(moal_private *priv, struct iwreq *wrq)
{
	int data[5], ret = 0, copy_len;
	mlan_ioctl_req *req = NULL;
	mlan_ds_11n_cfg *cfg_11n = NULL;
	int data_length = wrq->u.data.length;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	copy_len = MIN(sizeof(data), sizeof(int) * data_length);
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_11n_cfg));
	if (req == NULL) {
		LEAVE();
		return -ENOMEM;
	}
	cfg_11n = (mlan_ds_11n_cfg *)req->pbuf;
	cfg_11n->sub_command = MLAN_OID_11N_CFG_ADDBA_PARAM;
	req->req_id = MLAN_IOCTL_11N_CFG;
	if (data_length == 0) {
		req->action = MLAN_ACT_GET;
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = -EFAULT;
			goto error;
		}
		data[0] = cfg_11n->param.addba_param.timeout;
		data[1] = cfg_11n->param.addba_param.txwinsize;
		data[2] = cfg_11n->param.addba_param.rxwinsize;
		data[3] = cfg_11n->param.addba_param.txamsdu;
		data[4] = cfg_11n->param.addba_param.rxamsdu;
		PRINTM(MINFO,
		       "GET: timeout:%d txwinsize:%d rxwinsize:%d txamsdu=%d, rxamsdu=%d\n",
		       data[0], data[1], data[2], data[3], data[4]);
		wrq->u.data.length = 5;
		if (copy_to_user(wrq->u.data.pointer, data,
				 wrq->u.data.length * sizeof(int))) {
			PRINTM(MERROR, "Copy to user failed\n");
			ret = -EFAULT;
			goto error;
		}
	} else if (data_length == 5) {
		if (copy_from_user(data, wrq->u.data.pointer, copy_len)) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto error;
		}
		if (data[0] < 0 || data[0] > MLAN_DEFAULT_BLOCK_ACK_TIMEOUT) {
			PRINTM(MERROR, "Incorrect addba timeout value.\n");
			ret = -EFAULT;
			goto error;
		}
		if (data[1] <= 0 || data[1] > MLAN_AMPDU_MAX_TXWINSIZE ||
		    data[2] <= 0 || data[2] > MLAN_AMPDU_MAX_RXWINSIZE) {
			PRINTM(MERROR, "Incorrect Tx/Rx window size.\n");
			ret = -EFAULT;
			goto error;
		}
		cfg_11n->param.addba_param.timeout = data[0];
		cfg_11n->param.addba_param.txwinsize = data[1];
		cfg_11n->param.addba_param.rxwinsize = data[2];
		if (data[3] < 0 || data[3] > 1 || data[4] < 0 || data[4] > 1) {
			PRINTM(MERROR, "Incorrect Tx/Rx amsdu.\n");
			ret = -EFAULT;
			goto error;
		}
		cfg_11n->param.addba_param.txamsdu = data[3];
		cfg_11n->param.addba_param.rxamsdu = data[4];
		PRINTM(MINFO,
		       "SET: timeout:%d txwinsize:%d rxwinsize:%d txamsdu=%d rxamsdu=%d\n",
		       data[0], data[1], data[2], data[3], data[4]);
		req->action = MLAN_ACT_SET;
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = MLAN_STATUS_FAILURE;
			goto error;
		}
	} else {
		PRINTM(MERROR, "Invalid number of arguments\n");
		ret = -EINVAL;
		goto error;
	}
error:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_addba_para_updt ( moal_private * priv , struct iwreq * wrq ) { int data [ 5 ] , ret = 0 , copy_len ; mlan_ioctl_req * req = NULL ; mlan_ds_11n_cfg * cfg_11n = NULL ; int data_length = wrq -> u . data . length ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; copy_len = MIN ( sizeof ( data ) , sizeof ( int ) * data_length ) ; req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_11n_cfg ) ) ; if ( req == NULL ) { LEAVE ( ) ; return - ENOMEM ; } cfg_11n = ( mlan_ds_11n_cfg * ) req -> pbuf ; cfg_11n -> sub_command = MLAN_OID_11N_CFG_ADDBA_PARAM ; req -> req_id = MLAN_IOCTL_11N_CFG ; if ( data_length == 0 ) { req -> action = MLAN_ACT_GET ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto error ; } data [ 0 ] = cfg_11n -> param . addba_param . timeout ; data [ 1 ] = cfg_11n -> param . addba_param . txwinsize ; data [ 2 ] = cfg_11n -> param . addba_param . rxwinsize ; data [ 3 ] = cfg_11n -> param . addba_param . txamsdu ; data [ 4 ] = cfg_11n -> param . addba_param . rxamsdu ; PRINTM ( MINFO , " \n " , data [ 0 ] , data [ 1 ] , data [ 2 ] , data [ 3 ] , data [ 4 ] ) ; wrq -> u . data . length = 5 ; if ( copy_to_user ( wrq -> u . data . pointer , data , wrq -> u . data . length * sizeof ( int ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } } else if ( data_length == 5 ) { if ( copy_from_user ( data , wrq -> u . data . pointer , copy_len ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } if ( data [ 0 ] < 0 || data [ 0 ] > MLAN_DEFAULT_BLOCK_ACK_TIMEOUT ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } if ( data [ 1 ] <= 0 || data [ 1 ] > MLAN_AMPDU_MAX_TXWINSIZE || data [ 2 ] <= 0 || data [ 2 ] > MLAN_AMPDU_MAX_RXWINSIZE ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } cfg_11n -> param . addba_param . timeout = data [ 0 ] ; cfg_11n -> param . addba_param . txwinsize = data [ 1 ] ; cfg_11n -> param . addba_param . rxwinsize = data [ 2 ] ; if ( data [ 3 ] < 0 || data [ 3 ] > 1 || data [ 4 ] < 0 || data [ 4 ] > 1 ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } cfg_11n -> param . addba_param . txamsdu = data [ 3 ] ; cfg_11n -> param . addba_param . rxamsdu = data [ 4 ] ; PRINTM ( MINFO , " \n " , data [ 0 ] , data [ 1 ] , data [ 2 ] , data [ 3 ] , data [ 4 ] ) ; req -> action = MLAN_ACT_SET ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = MLAN_STATUS_FAILURE ; goto error ; } } else { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto error ; } error : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Set/Get add BA parameters
  @param priv     Pointer to the moal_private driver data struct
  @param wrq      A pointer to iwreq structure
@brief Set / Get add BA parameters @param priv Pointer to the moal_private driver data struct @param wrq A pointer to iwreq structure
/* Get Add BA parameters from MLAN */ /* Update Add BA parameters in MLAN */