software/drivers/sd8887/src/wlan/mapp/mlanutl/mlanoffload.c
int
process_txpowdisp(int argc, char *argv[])
{
	int ret = MLAN_STATUS_SUCCESS;
	int rateIdx, rates;
	int connected;
	struct ifreq ifr;
	t_u8 *buffer = NULL, *pos = NULL;
	t_u32 cmd_len = 0, cmd_header_len;
	struct eth_priv_cmd *cmd = NULL;
	HostCmd_DS_GEN *hostcmd;
	HostCmd_DS_802_11_RF_TX_POWER *pRfTxPower;
	RatePower_t ratePower[50];

	cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD);

	buffer = (t_u8 *)malloc(BUFFER_LENGTH);
	if (buffer == NULL) {
		fprintf(stderr, "Cannot alloc memory\n");
		ret = ENOMEM;
		goto done;
	}
	memset(buffer, 0, BUFFER_LENGTH);

	cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd));
	if (!cmd) {
		printf("ERR:Cannot allocate buffer for command!\n");
		ret = ENOMEM;
		goto done;
	}

	/* Fill up buffer */
#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT
	memset(cmd, 0, sizeof(struct eth_priv_cmd));
	memcpy(&cmd->buf, &buffer, sizeof(buffer));
#else
	cmd->buf = buffer;
#endif
	cmd->used_len = 0;
	cmd->total_len = BUFFER_LENGTH;

	/* buffer = MRVL_CMD<cmd> */
	strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP));
	strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD));

	/* buffer = MRVL_CMD<cmd><hostcmd_size><HostCmd_DS_GEN><CMD_DS> */
	hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32));

	/* Point after host command header */
	pos = (t_u8 *)hostcmd + S_DS_GEN;

	cmd_len = S_DS_GEN + sizeof(HostCmd_DS_802_11_RF_TX_POWER);

	pRfTxPower = (HostCmd_DS_802_11_RF_TX_POWER *)pos;

	memset(pRfTxPower, 0x00, sizeof(HostCmd_DS_802_11_RF_TX_POWER));

	hostcmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_TX_POWER);
	hostcmd->size = cpu_to_le16(cmd_len);
	hostcmd->seq_num = 0;
	hostcmd->result = 0;

	/* Put buffer length */
	memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32));

	/* Initialize the ifr structure */
	memset(&ifr, 0, sizeof(ifr));
	strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name));
	ifr.ifr_ifru.ifru_data = (void *)cmd;
	/* Perform ioctl */
	if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) {
		perror("ioctl[hostcmd]");
		printf("ERR:Command sending failed!\n");
		ret = -EFAULT;
		goto done;
	}

	connected = le16_to_cpu(pRfTxPower->current_level) ? TRUE : FALSE;

	if (connected) {
		display_channel();

		printf("\n");
		printf("  MinPower:  %2d\n", pRfTxPower->min_power);
		printf("  MaxPower:  %2d\n", pRfTxPower->max_power);
		printf("  Current:   %2d\n",
		       le16_to_cpu(pRfTxPower->current_level));
		printf("\n");
	}

	rates = get_txpwrcfg(ratePower);

	puts("");

	rateSort(ratePower, rates);

	printf("20MHz:");

	for (rateIdx = 0; rateIdx < 12; rateIdx++) {
		printf("%6s", get_ratestr(ratePower[rateIdx].rate));
	}

	printf("\n---------------------------------------"
	       "----------------------------------------\n%s",
	       connected ? "Active" : "Max   ");

	for (rateIdx = 0; rateIdx < 12; rateIdx++) {
		printf("%6d", ratePower[rateIdx].max);
	}

	if (!connected) {
		printf("\n---------------------------------------"
		       "----------------------------------------\n");

		process_chantrpcdisp(ratePower[0].rate, ratePower[12 - 1].rate);
	}

	puts("\n");

	/*
	 ** MCS0 -> MCS7
	 */

	printf("20MHz:");

	for (rateIdx = 12; rateIdx < 20; rateIdx++) {
		printf("%6s", get_ratestr(ratePower[rateIdx].rate));
	}

	printf("\n---------------------------------------"
	       "----------------------------------------\n%s",
	       connected ? "Active" : "Max   ");

	for (rateIdx = 12; rateIdx < 20; rateIdx++) {
		printf("%6d", ratePower[rateIdx].max);
	}

	if (!connected) {
		printf("\n---------------------------------------"
		       "----------------------------------------\n");

		process_chantrpcdisp(ratePower[12].rate,
				     ratePower[20 - 1].rate);
	}

	puts("\n");

	/*
	 ** MCS0 -> MCS7 @ 40MHz
	 */

	printf("40MHz:");

	for (rateIdx = 20; rateIdx < rates; rateIdx++) {
		printf("%6s", get_ratestr(ratePower[rateIdx].rate));
	}

	printf("\n---------------------------------------"
	       "----------------------------------------\n%s",
	       connected ? "Active" : "Max   ");

	for (rateIdx = 20; rateIdx < rates; rateIdx++) {
		printf("%6d", ratePower[rateIdx].max);
	}

	if (!connected) {
		printf("\n---------------------------------------"
		       "----------------------------------------\n");

		process_chantrpcdisp(ratePower[20].rate,
				     ratePower[rates - 1].rate);
	}

	puts("\n");

done:
	if (buffer)
		free(buffer);
	if (cmd)
		free(cmd);
	return ret;
}
/**
 *  @brief Issue a tx power display command
 *
 *  @param argc     number of arguments
 *  @param argv     A pointer to arguments array
 *
 *  @return         MLAN_STATUS_SUCCESS--success, otherwise--fail
 */
@brief Issue a tx power display command
@param argc     number of arguments
@param argv     A pointer to arguments array


@brief Issue a tx power display command @param argc number of arguments @param argv A pointer to arguments array
int
process_txpowdisp(int argc, char *argv[])
{
	int ret = MLAN_STATUS_SUCCESS;
	int rateIdx, rates;
	int connected;
	struct ifreq ifr;
	t_u8 *buffer = NULL, *pos = NULL;
	t_u32 cmd_len = 0, cmd_header_len;
	struct eth_priv_cmd *cmd = NULL;
	HostCmd_DS_GEN *hostcmd;
	HostCmd_DS_802_11_RF_TX_POWER *pRfTxPower;
	RatePower_t ratePower[50];
	cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD);
	buffer = (t_u8 *)malloc(BUFFER_LENGTH);
	if (buffer == NULL) {
		fprintf(stderr, "Cannot alloc memory\n");
		ret = ENOMEM;
		goto done;
	}
	memset(buffer, 0, BUFFER_LENGTH);
	cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd));
	if (!cmd) {
		printf("ERR:Cannot allocate buffer for command!\n");
		ret = ENOMEM;
		goto done;
	}
#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT
	memset(cmd, 0, sizeof(struct eth_priv_cmd));
	memcpy(&cmd->buf, &buffer, sizeof(buffer));
#else
	cmd->buf = buffer;
#endif
	cmd->used_len = 0;
	cmd->total_len = BUFFER_LENGTH;
	strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP));
	strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD));
	hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32));
	pos = (t_u8 *)hostcmd + S_DS_GEN;
	cmd_len = S_DS_GEN + sizeof(HostCmd_DS_802_11_RF_TX_POWER);
	pRfTxPower = (HostCmd_DS_802_11_RF_TX_POWER *)pos;
	memset(pRfTxPower, 0x00, sizeof(HostCmd_DS_802_11_RF_TX_POWER));
	hostcmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_TX_POWER);
	hostcmd->size = cpu_to_le16(cmd_len);
	hostcmd->seq_num = 0;
	hostcmd->result = 0;
	memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32));
	memset(&ifr, 0, sizeof(ifr));
	strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name));
	ifr.ifr_ifru.ifru_data = (void *)cmd;
	if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) {
		perror("ioctl[hostcmd]");
		printf("ERR:Command sending failed!\n");
		ret = -EFAULT;
		goto done;
	}
	connected = le16_to_cpu(pRfTxPower->current_level) ? TRUE : FALSE;
	if (connected) {
		display_channel();
		printf("\n");
		printf("  MinPower:  %2d\n", pRfTxPower->min_power);
		printf("  MaxPower:  %2d\n", pRfTxPower->max_power);
		printf("  Current:   %2d\n",
		       le16_to_cpu(pRfTxPower->current_level));
		printf("\n");
	}
	rates = get_txpwrcfg(ratePower);
	puts("");
	rateSort(ratePower, rates);
	printf("20MHz:");
	for (rateIdx = 0; rateIdx < 12; rateIdx++) {
		printf("%6s", get_ratestr(ratePower[rateIdx].rate));
	}
	printf("\n---------------------------------------"
	       "----------------------------------------\n%s",
	       connected ? "Active" : "Max   ");
	for (rateIdx = 0; rateIdx < 12; rateIdx++) {
		printf("%6d", ratePower[rateIdx].max);
	}
	if (!connected) {
		printf("\n---------------------------------------"
		       "----------------------------------------\n");
		process_chantrpcdisp(ratePower[0].rate, ratePower[12 - 1].rate);
	}
	puts("\n");
	printf("20MHz:");
	for (rateIdx = 12; rateIdx < 20; rateIdx++) {
		printf("%6s", get_ratestr(ratePower[rateIdx].rate));
	}
	printf("\n---------------------------------------"
	       "----------------------------------------\n%s",
	       connected ? "Active" : "Max   ");
	for (rateIdx = 12; rateIdx < 20; rateIdx++) {
		printf("%6d", ratePower[rateIdx].max);
	}
	if (!connected) {
		printf("\n---------------------------------------"
		       "----------------------------------------\n");
		process_chantrpcdisp(ratePower[12].rate,
				     ratePower[20 - 1].rate);
	}
	puts("\n");
	printf("40MHz:");
	for (rateIdx = 20; rateIdx < rates; rateIdx++) {
		printf("%6s", get_ratestr(ratePower[rateIdx].rate));
	}
	printf("\n---------------------------------------"
	       "----------------------------------------\n%s",
	       connected ? "Active" : "Max   ");
	for (rateIdx = 20; rateIdx < rates; rateIdx++) {
		printf("%6d", ratePower[rateIdx].max);
	}
	if (!connected) {
		printf("\n---------------------------------------"
		       "----------------------------------------\n");
		process_chantrpcdisp(ratePower[20].rate,
				     ratePower[rates - 1].rate);
	}
	puts("\n");
done:
	if (buffer)
		free(buffer);
	if (cmd)
		free(cmd);
	return ret;
}
int process_txpowdisp ( int argc , char * argv [ ] ) { int ret = MLAN_STATUS_SUCCESS ; int rateIdx , rates ; int connected ; struct ifreq ifr ; t_u8 * buffer = NULL , * pos = NULL ; t_u32 cmd_len = 0 , cmd_header_len ; struct eth_priv_cmd * cmd = NULL ; HostCmd_DS_GEN * hostcmd ; HostCmd_DS_802_11_RF_TX_POWER * pRfTxPower ; RatePower_t ratePower [ 50 ] ; cmd_header_len = strlen ( CMD_NXP ) + strlen ( HOSTCMD ) ; buffer = ( t_u8 * ) malloc ( BUFFER_LENGTH ) ; if ( buffer == NULL ) { fprintf ( stderr , " \n " ) ; ret = ENOMEM ; goto done ; } memset ( buffer , 0 , BUFFER_LENGTH ) ; cmd = ( struct eth_priv_cmd * ) malloc ( sizeof ( struct eth_priv_cmd ) ) ; if ( ! cmd ) { printf ( " \n " ) ; ret = ENOMEM ; goto done ; } #ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT memset ( cmd , 0 , sizeof ( struct eth_priv_cmd ) ) ; memcpy ( & cmd -> buf , & buffer , sizeof ( buffer ) ) ; #else cmd -> buf = buffer ; #endif cmd -> used_len = 0 ; cmd -> total_len = BUFFER_LENGTH ; strncpy ( ( char * ) buffer , CMD_NXP , strlen ( CMD_NXP ) ) ; strncpy ( ( char * ) buffer + strlen ( CMD_NXP ) , HOSTCMD , strlen ( HOSTCMD ) ) ; hostcmd = ( HostCmd_DS_GEN * ) ( buffer + cmd_header_len + sizeof ( t_u32 ) ) ; pos = ( t_u8 * ) hostcmd + S_DS_GEN ; cmd_len = S_DS_GEN + sizeof ( HostCmd_DS_802_11_RF_TX_POWER ) ; pRfTxPower = ( HostCmd_DS_802_11_RF_TX_POWER * ) pos ; memset ( pRfTxPower , 0x00 , sizeof ( HostCmd_DS_802_11_RF_TX_POWER ) ) ; hostcmd -> command = cpu_to_le16 ( HostCmd_CMD_802_11_RF_TX_POWER ) ; hostcmd -> size = cpu_to_le16 ( cmd_len ) ; hostcmd -> seq_num = 0 ; hostcmd -> result = 0 ; memcpy ( buffer + cmd_header_len , & cmd_len , sizeof ( t_u32 ) ) ; memset ( & ifr , 0 , sizeof ( ifr ) ) ; strncpy ( ifr . ifr_ifrn . ifrn_name , dev_name , strlen ( dev_name ) ) ; ifr . ifr_ifru . ifru_data = ( void * ) cmd ; if ( ioctl ( sockfd , MLAN_ETH_PRIV , & ifr ) ) { perror ( " " ) ; printf ( " \n " ) ; ret = - EFAULT ; goto done ; } connected = le16_to_cpu ( pRfTxPower -> current_level ) ? TRUE : FALSE ; if ( connected ) { display_channel ( ) ; printf ( " \n " ) ; printf ( " \n " , pRfTxPower -> min_power ) ; printf ( " \n " , pRfTxPower -> max_power ) ; printf ( " \n " , le16_to_cpu ( pRfTxPower -> current_level ) ) ; printf ( " \n " ) ; } rates = get_txpwrcfg ( ratePower ) ; puts ( " " ) ; rateSort ( ratePower , rates ) ; printf ( " " ) ; for ( rateIdx = 0 ; rateIdx < 12 ; rateIdx ++ ) { printf ( " " , get_ratestr ( ratePower [ rateIdx ] . rate ) ) ; } printf ( " \n " " \n " , connected ? " " : " " ) ; for ( rateIdx = 0 ; rateIdx < 12 ; rateIdx ++ ) { printf ( " " , ratePower [ rateIdx ] . max ) ; } if ( ! connected ) { printf ( " \n " " \n " ) ; process_chantrpcdisp ( ratePower [ 0 ] . rate , ratePower [ 12 - 1 ] . rate ) ; } puts ( " \n " ) ; printf ( " " ) ; for ( rateIdx = 12 ; rateIdx < 20 ; rateIdx ++ ) { printf ( " " , get_ratestr ( ratePower [ rateIdx ] . rate ) ) ; } printf ( " \n " " \n " , connected ? " " : " " ) ; for ( rateIdx = 12 ; rateIdx < 20 ; rateIdx ++ ) { printf ( " " , ratePower [ rateIdx ] . max ) ; } if ( ! connected ) { printf ( " \n " " \n " ) ; process_chantrpcdisp ( ratePower [ 12 ] . rate , ratePower [ 20 - 1 ] . rate ) ; } puts ( " \n " ) ; printf ( " " ) ; for ( rateIdx = 20 ; rateIdx < rates ; rateIdx ++ ) { printf ( " " , get_ratestr ( ratePower [ rateIdx ] . rate ) ) ; } printf ( " \n " " \n " , connected ? " " : " " ) ; for ( rateIdx = 20 ; rateIdx < rates ; rateIdx ++ ) { printf ( " " , ratePower [ rateIdx ] . max ) ; } if ( ! connected ) { printf ( " \n " " \n " ) ; process_chantrpcdisp ( ratePower [ 20 ] . rate , ratePower [ rates - 1 ] . rate ) ; } puts ( " \n " ) ; done : if ( buffer ) free ( buffer ) ; if ( cmd ) free ( cmd ) ; return ret ; }
@brief Issue a tx power display command
  @param argc     number of arguments
  @param argv     A pointer to arguments array
@brief Issue a tx power display command @param argc number of arguments @param argv A pointer to arguments array
/* Fill up buffer */ /* buffer = MRVL_CMD<cmd> */ /* buffer = MRVL_CMD<cmd><hostcmd_size><HostCmd_DS_GEN><CMD_DS> */ /* Point after host command header */ /* Put buffer length */ /* Initialize the ifr structure */ /* Perform ioctl */ /*
	 ** MCS0 -> MCS7
	 */ /*
	 ** MCS0 -> MCS7 @ 40MHz
	 */