software/drivers/sd8887/src/wlan/mlinux/moal_priv.c
/**
 *  @brief Enable/Disable TX Aggregation
 *
 *  @param priv     Pointer to the moal_private driver data struct
 *  @param wrq      A pointer to iwreq structure
 *
 *  @return         0 --success, otherwise fail
 */
@brief Enable/Disable TX Aggregation
@param priv     Pointer to the moal_private driver data struct
@param wrq      A pointer to iwreq structure

@return         0 --success, otherwise fail
@brief Enable / Disable TX Aggregation @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_11n_prio_tbl(moal_private *priv, struct iwreq *wrq)
{
	int data[MAX_NUM_TID * 2], i, j, copy_len;
	mlan_ioctl_req *req = NULL;
	mlan_ds_11n_cfg *cfg_11n = NULL;
	int ret = 0;
	int data_length = wrq->u.data.length;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	if ((wrq->u.data.pointer == NULL)) {
		LEAVE();
		return -EINVAL;
	}
	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_AGGR_PRIO_TBL;
	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;
		}
		wrq->u.data.length = MAX_NUM_TID * 2;
		for (i = 0, j = 0; i < (wrq->u.data.length); i = i + 2, ++j) {
			data[i] = cfg_11n->param.aggr_prio_tbl.ampdu[j];
			data[i + 1] = cfg_11n->param.aggr_prio_tbl.amsdu[j];
		}
		if (copy_to_user(wrq->u.data.pointer, data,
				 sizeof(int) * wrq->u.data.length)) {
			PRINTM(MERROR, "Copy to user failed\n");
			ret = -EFAULT;
			goto error;
		}
	} else if (data_length == 16) {
		if (copy_from_user(data, wrq->u.data.pointer, copy_len)) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto error;
		}
		for (i = 0, j = 0; i < (data_length); i = i + 2, ++j) {
			if ((data[i] > 7 && data[i] != 0xff) ||
			    (data[i + 1] > 7 && data[i + 1] != 0xff)) {
				PRINTM(MERROR,
				       "Invalid priority, valid value 0-7 or 0xff.\n");
				ret = -EFAULT;
				goto error;
			}
			cfg_11n->param.aggr_prio_tbl.ampdu[j] = data[i];
			cfg_11n->param.aggr_prio_tbl.amsdu[j] = data[i + 1];
		}
		req->action = MLAN_ACT_SET;
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = -EFAULT;
			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_11n_prio_tbl ( moal_private * priv , struct iwreq * wrq ) { int data [ MAX_NUM_TID * 2 ] , i , j , copy_len ; mlan_ioctl_req * req = NULL ; mlan_ds_11n_cfg * cfg_11n = NULL ; int ret = 0 ; int data_length = wrq -> u . data . length ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; if ( ( wrq -> u . data . pointer == NULL ) ) { LEAVE ( ) ; return - EINVAL ; } 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_AGGR_PRIO_TBL ; 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 ; } wrq -> u . data . length = MAX_NUM_TID * 2 ; for ( i = 0 , j = 0 ; i < ( wrq -> u . data . length ) ; i = i + 2 , ++ j ) { data [ i ] = cfg_11n -> param . aggr_prio_tbl . ampdu [ j ] ; data [ i + 1 ] = cfg_11n -> param . aggr_prio_tbl . amsdu [ j ] ; } if ( copy_to_user ( wrq -> u . data . pointer , data , sizeof ( int ) * wrq -> u . data . length ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } } else if ( data_length == 16 ) { if ( copy_from_user ( data , wrq -> u . data . pointer , copy_len ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } for ( i = 0 , j = 0 ; i < ( data_length ) ; i = i + 2 , ++ j ) { if ( ( data [ i ] > 7 && data [ i ] != 0xff ) || ( data [ i + 1 ] > 7 && data [ i + 1 ] != 0xff ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } cfg_11n -> param . aggr_prio_tbl . ampdu [ j ] = data [ i ] ; cfg_11n -> param . aggr_prio_tbl . amsdu [ j ] = data [ i + 1 ] ; } req -> action = MLAN_ACT_SET ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto error ; } } else { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto error ; } error : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Enable/Disable TX Aggregation
  @param priv     Pointer to the moal_private driver data struct
  @param wrq      A pointer to iwreq structure
@brief Enable / Disable TX Aggregation @param priv Pointer to the moal_private driver data struct @param wrq A pointer to iwreq structure
/* Get aggr priority table from MLAN */ /* Update aggr priority table in MLAN */