software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Creates a Tx Rate Config request and sends to the driver
 *
 *   Usage: "txratecfg <datarate>"
 *
 *  @param argc     Number of arguments
 *  @param argv     Pointer to the arguments
 *  @return         UAP_SUCCESS/UAP_FAILURE
 */
@brief Creates a Tx Rate Config request and sends to the driver
Usage: "txratecfg "

@param argc     Number of arguments
@param argv     Pointer to the arguments
@return         UAP_SUCCESS/UAP_FAILURE
@brief Creates a Tx Rate Config request and sends to the driver Usage : " txratecfg " @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
int
apcmd_tx_rate_cfg(int argc, char *argv[])
{
	int opt;
	int status = 0;
	tx_rate_cfg_t tx_rate_config;
	struct ifreq ifr;
	t_s32 sockfd;
	HTCap_t htcap;
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			print_txratecfg_usage();
			return UAP_SUCCESS;
		}
	}
	argc -= optind;
	argv += optind;
	if (argc > 4) {
		printf("ERR:wrong arguments! Only 0~4 arguments are supported.\n");
		print_txratecfg_usage();
		return UAP_FAILURE;
	}
	if (argc && (is_input_valid(TXRATECFG, argc, argv) != UAP_SUCCESS)) {
		print_txratecfg_usage();
		return UAP_FAILURE;
	}
	memset(&tx_rate_config, 0, sizeof(tx_rate_cfg_t));
	tx_rate_config.subcmd = UAP_TX_RATE_CFG;
	if (argc) {
		tx_rate_config.action = ACTION_SET;
		tx_rate_config.rate_format = A2HEXDECIMAL(argv[0]);
		if (argc >= 2)
			tx_rate_config.rate = A2HEXDECIMAL(argv[1]);
		if (argc == 3)
			tx_rate_config.nss = A2HEXDECIMAL(argv[2]);
		tx_rate_config.user_data_cnt = argc;
		if (get_bss_status(&status) != UAP_SUCCESS) {
			printf("ERR:Cannot get current bss status!\n");
			return UAP_FAILURE;
		}
		if (UAP_SUCCESS == get_sys_cfg_11n(&htcap)) {
			if (htcap.supported_mcs_set[0] &&
			    (status == UAP_BSS_START)) {
				if (((tx_rate_config.rate >= 0) &&
				     (tx_rate_config.rate <= 7))
				    &&
				    (IS_11N_20MHZ_SHORTGI_ENABLED
				     (htcap.ht_cap_info) &&
				     IS_11N_GF_ENABLED(htcap.ht_cap_info))) {
					printf("ERR: Invalid rate for bss in (20MHz Short GI + Green Field) mode\n");
					return UAP_FAILURE;
				}
				if ((tx_rate_config.rate == 32) &&
				    (!(IS_11N_40MHZ_ENABLED
				       (htcap.ht_cap_info)))) {
					printf("ERR:uAP must be configured to operate in 40MHz if tx_rate is MCS32\n");
					return UAP_FAILURE;
				}
			}
		}
	}
	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printf("ERR:Cannot open socket\n");
		return UAP_FAILURE;
	}
	memset(&ifr, 0, sizeof(ifr));
	strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name));
	ifr.ifr_ifru.ifru_data = (void *)&tx_rate_config;
	errno = 0;
	if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) {
		printf("ERR:UAP_IOCTL_CMD fail\n");
		close(sockfd);
		return UAP_FAILURE;
	}
	if (argc) {
		printf("Transmit Rate setting successful\n");
	} else {
		printf("Tx Rate Configuration: \n");
		if (tx_rate_config.rate_format == 0xFF) {
			printf("    Type:       0xFF (Auto)\n");
		} else if (tx_rate_config.rate_format <= 2) {
			printf("    Type:       %d (%s)\n",
			       tx_rate_config.rate_format,
			       rate_format[tx_rate_config.rate_format]);
			if (tx_rate_config.rate_format == 0)
				printf("    Rate Index: %d (%s)\n",
				       tx_rate_config.rate,
				       lg_rate[tx_rate_config.rate]);
			else if (tx_rate_config.rate_format >= 1)
				printf("    MCS Index:  %d\n",
				       (int)tx_rate_config.rate);
			if (tx_rate_config.rate_format == 2)
				printf("    NSS:        %d\n",
				       (int)tx_rate_config.nss);
		} else {
			printf("    Unknown rate format.\n");
		}
	}
	close(sockfd);
	return UAP_SUCCESS;
}
int apcmd_tx_rate_cfg ( int argc , char * argv [ ] ) { int opt ; int status = 0 ; tx_rate_cfg_t tx_rate_config ; struct ifreq ifr ; t_s32 sockfd ; HTCap_t htcap ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : print_txratecfg_usage ( ) ; return UAP_SUCCESS ; } } argc -= optind ; argv += optind ; if ( argc > 4 ) { printf ( " \n " ) ; print_txratecfg_usage ( ) ; return UAP_FAILURE ; } if ( argc && ( is_input_valid ( TXRATECFG , argc , argv ) != UAP_SUCCESS ) ) { print_txratecfg_usage ( ) ; return UAP_FAILURE ; } memset ( & tx_rate_config , 0 , sizeof ( tx_rate_cfg_t ) ) ; tx_rate_config . subcmd = UAP_TX_RATE_CFG ; if ( argc ) { tx_rate_config . action = ACTION_SET ; tx_rate_config . rate_format = A2HEXDECIMAL ( argv [ 0 ] ) ; if ( argc >= 2 ) tx_rate_config . rate = A2HEXDECIMAL ( argv [ 1 ] ) ; if ( argc == 3 ) tx_rate_config . nss = A2HEXDECIMAL ( argv [ 2 ] ) ; tx_rate_config . user_data_cnt = argc ; if ( get_bss_status ( & status ) != UAP_SUCCESS ) { printf ( " \n " ) ; return UAP_FAILURE ; } if ( UAP_SUCCESS == get_sys_cfg_11n ( & htcap ) ) { if ( htcap . supported_mcs_set [ 0 ] && ( status == UAP_BSS_START ) ) { if ( ( ( tx_rate_config . rate >= 0 ) && ( tx_rate_config . rate <= 7 ) ) && ( IS_11N_20MHZ_SHORTGI_ENABLED ( htcap . ht_cap_info ) && IS_11N_GF_ENABLED ( htcap . ht_cap_info ) ) ) { printf ( " \n " ) ; return UAP_FAILURE ; } if ( ( tx_rate_config . rate == 32 ) && ( ! ( IS_11N_40MHZ_ENABLED ( htcap . ht_cap_info ) ) ) ) { printf ( " \n " ) ; return UAP_FAILURE ; } } } } if ( ( sockfd = socket ( AF_INET , SOCK_STREAM , 0 ) ) < 0 ) { printf ( " \n " ) ; return UAP_FAILURE ; } memset ( & ifr , 0 , sizeof ( ifr ) ) ; strncpy ( ifr . ifr_ifrn . ifrn_name , dev_name , strlen ( dev_name ) ) ; ifr . ifr_ifru . ifru_data = ( void * ) & tx_rate_config ; errno = 0 ; if ( ioctl ( sockfd , UAP_IOCTL_CMD , & ifr ) ) { printf ( " \n " ) ; close ( sockfd ) ; return UAP_FAILURE ; } if ( argc ) { printf ( " \n " ) ; } else { printf ( " \n " ) ; if ( tx_rate_config . rate_format == 0xFF ) { printf ( " \n " ) ; } else if ( tx_rate_config . rate_format <= 2 ) { printf ( " \n " , tx_rate_config . rate_format , rate_format [ tx_rate_config . rate_format ] ) ; if ( tx_rate_config . rate_format == 0 ) printf ( " \n " , tx_rate_config . rate , lg_rate [ tx_rate_config . rate ] ) ; else if ( tx_rate_config . rate_format >= 1 ) printf ( " \n " , ( int ) tx_rate_config . rate ) ; if ( tx_rate_config . rate_format == 2 ) printf ( " \n " , ( int ) tx_rate_config . nss ) ; } else { printf ( " \n " ) ; } } close ( sockfd ) ; return UAP_SUCCESS ; }
@brief Creates a Tx Rate Config request and sends to the driver
   Usage: "txratecfg <datarate>"
@brief Creates a Tx Rate Config request and sends to the driver Usage : " txratecfg <datarate > "
/* Check arguments */ /* If bss is already started and uAP is in (short GI in 20 MHz + GF) mode, block MCS0-MCS7 rates */ /* Open socket */ /* Initialize the ifr structure */ /* Perform ioctl */ /* GET operation */ /* format */ /* Close socket */