software/drivers/sd8887/src/wlan/mlinux/moal_priv.c
/**
 *  @brief Set/Get 11n configuration request
 *
 *  @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 11n configuration request
@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 11n configuration request @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_tx_cfg(moal_private *priv, struct iwreq *wrq)
{
	int data[2], 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 (data_length > 2) {
		PRINTM(MERROR, "Invalid number of arguments\n");
		ret = -EINVAL;
		goto done;
	}
	copy_len = MIN(sizeof(data), sizeof(int) * data_length);
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_11n_cfg));
	if (req == NULL) {
		ret = -ENOMEM;
		goto done;
	}
	cfg_11n = (mlan_ds_11n_cfg *)req->pbuf;
	cfg_11n->sub_command = MLAN_OID_11N_CFG_TX;
	req->req_id = MLAN_IOCTL_11N_CFG;
	if (data_length == 0) {
		req->action = MLAN_ACT_GET;
		cfg_11n->param.tx_cfg.misc_cfg = BAND_SELECT_BG;
	} else {
		if (copy_from_user(data, wrq->u.data.pointer, copy_len)) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		}
		cfg_11n->param.tx_cfg.httxcap = data[0];
		PRINTM(MINFO, "SET: httxcap:0x%x\n", data[0]);
		cfg_11n->param.tx_cfg.misc_cfg = BAND_SELECT_BOTH;
		if (data_length == 2) {
			if (data[1] != BAND_SELECT_BG &&
			    data[1] != BAND_SELECT_A &&
			    data[1] != BAND_SELECT_BOTH) {
				PRINTM(MERROR, "Invalid band selection\n");
				ret = -EINVAL;
				goto done;
			}
			cfg_11n->param.tx_cfg.misc_cfg = data[1];
			PRINTM(MINFO, "SET: httxcap band:0x%x\n", data[1]);
		}
		req->action = MLAN_ACT_SET;
	}
	status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	}
	data[0] = cfg_11n->param.tx_cfg.httxcap;
	if (req->action == MLAN_ACT_GET) {
		data_length = 1;
		cfg_11n->param.tx_cfg.httxcap = 0;
		cfg_11n->param.tx_cfg.misc_cfg = BAND_SELECT_A;
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = -EFAULT;
			goto done;
		}
		if (cfg_11n->param.tx_cfg.httxcap != data[0]) {
			data_length = 2;
			data[1] = cfg_11n->param.tx_cfg.httxcap;
			PRINTM(MINFO, "GET: httxcap for 2.4GHz:0x%x\n",
			       data[0]);
			PRINTM(MINFO, "GET: httxcap for 5GHz:0x%x\n", data[1]);
		} else
			PRINTM(MINFO, "GET: httxcap:0x%x\n", data[0]);
	}
	if (copy_to_user(wrq->u.data.pointer, data, sizeof(data))) {
		PRINTM(MERROR, "Copy to user failed\n");
		ret = -EFAULT;
		goto done;
	}
	wrq->u.data.length = data_length;
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_11n_tx_cfg ( moal_private * priv , struct iwreq * wrq ) { int data [ 2 ] , 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 ( data_length > 2 ) { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto done ; } copy_len = MIN ( sizeof ( data ) , sizeof ( int ) * data_length ) ; req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_11n_cfg ) ) ; if ( req == NULL ) { ret = - ENOMEM ; goto done ; } cfg_11n = ( mlan_ds_11n_cfg * ) req -> pbuf ; cfg_11n -> sub_command = MLAN_OID_11N_CFG_TX ; req -> req_id = MLAN_IOCTL_11N_CFG ; if ( data_length == 0 ) { req -> action = MLAN_ACT_GET ; cfg_11n -> param . tx_cfg . misc_cfg = BAND_SELECT_BG ; } else { if ( copy_from_user ( data , wrq -> u . data . pointer , copy_len ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } cfg_11n -> param . tx_cfg . httxcap = data [ 0 ] ; PRINTM ( MINFO , " \n " , data [ 0 ] ) ; cfg_11n -> param . tx_cfg . misc_cfg = BAND_SELECT_BOTH ; if ( data_length == 2 ) { if ( data [ 1 ] != BAND_SELECT_BG && data [ 1 ] != BAND_SELECT_A && data [ 1 ] != BAND_SELECT_BOTH ) { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto done ; } cfg_11n -> param . tx_cfg . misc_cfg = data [ 1 ] ; PRINTM ( MINFO , " \n " , data [ 1 ] ) ; } req -> action = MLAN_ACT_SET ; } status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } data [ 0 ] = cfg_11n -> param . tx_cfg . httxcap ; if ( req -> action == MLAN_ACT_GET ) { data_length = 1 ; cfg_11n -> param . tx_cfg . httxcap = 0 ; cfg_11n -> param . tx_cfg . misc_cfg = BAND_SELECT_A ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } if ( cfg_11n -> param . tx_cfg . httxcap != data [ 0 ] ) { data_length = 2 ; data [ 1 ] = cfg_11n -> param . tx_cfg . httxcap ; PRINTM ( MINFO , " \n " , data [ 0 ] ) ; PRINTM ( MINFO , " \n " , data [ 1 ] ) ; } else PRINTM ( MINFO , " \n " , data [ 0 ] ) ; } if ( copy_to_user ( wrq -> u . data . pointer , data , sizeof ( data ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } wrq -> u . data . length = data_length ; done : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Set/Get 11n configuration request
  @param priv     Pointer to the moal_private driver data struct
  @param wrq      A pointer to iwreq structure
@brief Set / Get 11n configuration request @param priv Pointer to the moal_private driver data struct @param wrq A pointer to iwreq structure
/* Get 11n tx parameters from MLAN */ /* Update 11n tx parameters in MLAN */