Exemplo n.º 1
0
int showtraffic()
{
	struct iwreq wrq;
	int sfd, ret, i;
	unsigned long long rxtotal = 0;
	unsigned long long txtotal = 0;
	RT_MBSS_STATISTICS_TABLE stable2G;
	RT_MBSS_STATISTICS_TABLE stable5G;
	unsigned int amount = 0;
	FILE *fp = NULL;
	char ifname2G[32] = {0};
	char ifname5G[32] = {0};

	tcapi_get_string("WLan_Common", "wl0_ifname", ifname2G);

	if(ifname2G[0] == '\0' )
	{
		printf("[iwpriv.c]there is no 2G WiFi interface name\n");
		return -1;
	}

	fp = fopen(WIFI_TRAFFIC_PATH, "w");
	if(!fp)
	{
		printf("[iwpriv.c]Cannot write to file:%s\n", WIFI_TRAFFIC_PATH);
		return -2;
	}

	sfd = socket(AF_INET, SOCK_DGRAM,0);
	memset(&stable2G, 0, sizeof(RT_MBSS_STATISTICS_TABLE));
	wrq.u.data.flags = OID_802_11_STATISTICS;
	strcpy(wrq.ifr_name, ifname2G);
	wrq.u.data.length = sizeof(stable2G);
	wrq.u.data.pointer = &stable2G;
	ret = ioctl(sfd, RT_PRIV_IOCTL, &wrq);

	rxtotal = 0;
	txtotal = 0;
	amount = __constant_cpu_to_le32(stable2G.Num);

#ifdef TCSUPPORT_WLAN_RT6856
#else
	if( amount > 4 )
	{
		amount = 4;
	}
#endif

	if (!ret) {
		printf("\t");
		fprintf(fp, "\t");
		for (i = 0; i < amount; i++)
		{
			printf("mssid_%d\t", i);
			fprintf(fp, "mssid_%d\t", i);
		}
		printf("TotalCount\n");
		fprintf(fp, "TotalCount\n");
		
		printf("2GRxCount:");
		fprintf(fp, "2GRxCount:");
		for (i = 0; i < amount; i++)
		{
			printf("%u\t", __constant_le32_to_cpu(stable2G.MbssEntry[i].ReceivedByteCount));
			fprintf(fp, "%u\t", __constant_le32_to_cpu(stable2G.MbssEntry[i].ReceivedByteCount));
			rxtotal += __constant_le32_to_cpu(stable2G.MbssEntry[i].ReceivedByteCount);
		}
		printf("%llu\n", rxtotal);
		fprintf(fp, "%llu\n", rxtotal);

		printf("2GTxCount:");
		fprintf(fp, "2GTxCount:");
		for (i = 0; i < amount; i++)
		{
			printf("%u\t", __constant_le32_to_cpu(stable2G.MbssEntry[i].TransmittedByteCount));
			fprintf(fp, "%u\t", __constant_le32_to_cpu(stable2G.MbssEntry[i].TransmittedByteCount));
			txtotal += __constant_le32_to_cpu(stable2G.MbssEntry[i].TransmittedByteCount);
		}
		printf("%llu\n", txtotal);
		fprintf(fp, "%llu\n", txtotal);
	}

	tcapi_get_string("WLan_Common", "wl1_ifname", ifname5G);
	if(ifname5G[0] == '\0' )
	{
		//printf("[iwpriv.c]has no 5G WiFi interface\n");
		fclose(fp);
		close(sfd);
		return 1;
	}

	memset(&stable5G, 0, sizeof(RT_MBSS_STATISTICS_TABLE));
	strcpy(wrq.ifr_name, ifname5G);
	wrq.u.data.pointer = &stable5G;
	ret = ioctl(sfd, RT_PRIV_IOCTL, &wrq);

	rxtotal = 0;
	txtotal = 0;
	amount = __constant_cpu_to_le32(stable5G.Num);

#ifdef TCSUPPORT_WLAN_RT6856
#else
	if( amount > 4 )
	{
		amount = 4;
	}
#endif

	if (!ret) {
		printf("5GRxCount:");
		fprintf(fp, "5GRxCount:");
		for (i = 0; i < amount; i++)
		{
			printf("%u\t", __constant_le32_to_cpu(stable5G.MbssEntry[i].ReceivedByteCount));
			fprintf(fp, "%u\t", __constant_le32_to_cpu(stable5G.MbssEntry[i].ReceivedByteCount));
			rxtotal += __constant_le32_to_cpu(stable5G.MbssEntry[i].ReceivedByteCount);
		}
		printf("%llu\n", rxtotal);
		fprintf(fp, "%llu\n", rxtotal);

		printf("5GTxCount:");
		fprintf(fp, "5GTxCount:");
		for (i = 0; i < amount; i++)
		{
			printf("%u\t", __constant_le32_to_cpu(stable5G.MbssEntry[i].TransmittedByteCount));
			fprintf(fp, "%u\t", __constant_le32_to_cpu(stable5G.MbssEntry[i].TransmittedByteCount));
			txtotal += __constant_le32_to_cpu(stable5G.MbssEntry[i].TransmittedByteCount);
		}
		printf("%llu\n", txtotal);
		fprintf(fp, "%llu\n", txtotal);
	}

	fclose(fp);
	close(sfd);
	return 0;
}
Exemplo n.º 2
0
static int ufs_fill_super(struct super_block *sb, void *data, int silent)
{
	struct ufs_sb_info * sbi;
	struct ufs_sb_private_info * uspi;
	struct ufs_super_block_first * usb1;
	struct ufs_super_block_second * usb2;
	struct ufs_super_block_third * usb3;
	struct ufs_buffer_head * ubh;	
	struct inode *inode;
	unsigned block_size, super_block_size;
	unsigned flags;

	uspi = NULL;
	ubh = NULL;
	flags = 0;
	
	UFSD(("ENTER\n"))
		
	sbi = kmalloc(sizeof(struct ufs_sb_info), GFP_KERNEL);
	if (!sbi)
		goto failed_nomem;
	sb->s_fs_info = sbi;
	memset(sbi, 0, sizeof(struct ufs_sb_info));

	UFSD(("flag %u\n", (int)(sb->s_flags & MS_RDONLY)))
	
#ifndef CONFIG_UFS_FS_WRITE
	if (!(sb->s_flags & MS_RDONLY)) {
		printk("ufs was compiled with read-only support, "
		"can't be mounted as read-write\n");
		goto failed;
	}
#endif
	/*
	 * Set default mount options
	 * Parse mount options
	 */
	sbi->s_mount_opt = 0;
	ufs_set_opt (sbi->s_mount_opt, ONERROR_LOCK);
	if (!ufs_parse_options ((char *) data, &sbi->s_mount_opt)) {
		printk("wrong mount options\n");
		goto failed;
	}
	if (!(sbi->s_mount_opt & UFS_MOUNT_UFSTYPE)) {
		printk("You didn't specify the type of your ufs filesystem\n\n"
		"mount -t ufs -o ufstype="
		"sun|sunx86|44bsd|old|hp|nextstep|netxstep-cd|openstep ...\n\n"
		">>>WARNING<<< Wrong ufstype may corrupt your filesystem, "
		"default is ufstype=old\n");
		ufs_set_opt (sbi->s_mount_opt, UFSTYPE_OLD);
	}

	sbi->s_uspi = uspi =
		kmalloc (sizeof(struct ufs_sb_private_info), GFP_KERNEL);
	if (!uspi)
		goto failed;

	/* Keep 2Gig file limit. Some UFS variants need to override 
	   this but as I don't know which I'll let those in the know loosen
	   the rules */
	   
	switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) {
	case UFS_MOUNT_UFSTYPE_44BSD:
		UFSD(("ufstype=44bsd\n"))
		uspi->s_fsize = block_size = 512;
		uspi->s_fmask = ~(512 - 1);
		uspi->s_fshift = 9;
		uspi->s_sbsize = super_block_size = 1536;
		uspi->s_sbbase = 0;
		flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD;
		break;
		
	case UFS_MOUNT_UFSTYPE_SUN:
		UFSD(("ufstype=sun\n"))
		uspi->s_fsize = block_size = 1024;
		uspi->s_fmask = ~(1024 - 1);
		uspi->s_fshift = 10;
		uspi->s_sbsize = super_block_size = 2048;
		uspi->s_sbbase = 0;
		uspi->s_maxsymlinklen = 56;
		flags |= UFS_DE_OLD | UFS_UID_EFT | UFS_ST_SUN | UFS_CG_SUN;
		break;

	case UFS_MOUNT_UFSTYPE_SUNx86:
		UFSD(("ufstype=sunx86\n"))
		uspi->s_fsize = block_size = 1024;
		uspi->s_fmask = ~(1024 - 1);
		uspi->s_fshift = 10;
		uspi->s_sbsize = super_block_size = 2048;
		uspi->s_sbbase = 0;
		uspi->s_maxsymlinklen = 56;
		flags |= UFS_DE_OLD | UFS_UID_EFT | UFS_ST_SUNx86 | UFS_CG_SUN;
		break;

	case UFS_MOUNT_UFSTYPE_OLD:
		UFSD(("ufstype=old\n"))
		uspi->s_fsize = block_size = 1024;
		uspi->s_fmask = ~(1024 - 1);
		uspi->s_fshift = 10;
		uspi->s_sbsize = super_block_size = 2048;
		uspi->s_sbbase = 0;
		flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_OLD | UFS_CG_OLD;
		if (!(sb->s_flags & MS_RDONLY)) {
			printk(KERN_INFO "ufstype=old is supported read-only\n"); 
			sb->s_flags |= MS_RDONLY;
		}
		break;
	
	case UFS_MOUNT_UFSTYPE_NEXTSTEP:
		UFSD(("ufstype=nextstep\n"))
		uspi->s_fsize = block_size = 1024;
		uspi->s_fmask = ~(1024 - 1);
		uspi->s_fshift = 10;
		uspi->s_sbsize = super_block_size = 2048;
		uspi->s_sbbase = 0;
		flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_OLD | UFS_CG_OLD;
		if (!(sb->s_flags & MS_RDONLY)) {
			printk(KERN_INFO "ufstype=nextstep is supported read-only\n");
			sb->s_flags |= MS_RDONLY;
		}
		break;
	
	case UFS_MOUNT_UFSTYPE_NEXTSTEP_CD:
		UFSD(("ufstype=nextstep-cd\n"))
		uspi->s_fsize = block_size = 2048;
		uspi->s_fmask = ~(2048 - 1);
		uspi->s_fshift = 11;
		uspi->s_sbsize = super_block_size = 2048;
		uspi->s_sbbase = 0;
		flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_OLD | UFS_CG_OLD;
		if (!(sb->s_flags & MS_RDONLY)) {
			printk(KERN_INFO "ufstype=nextstep-cd is supported read-only\n");
			sb->s_flags |= MS_RDONLY;
		}
		break;
	
	case UFS_MOUNT_UFSTYPE_OPENSTEP:
		UFSD(("ufstype=openstep\n"))
		uspi->s_fsize = block_size = 1024;
		uspi->s_fmask = ~(1024 - 1);
		uspi->s_fshift = 10;
		uspi->s_sbsize = super_block_size = 2048;
		uspi->s_sbbase = 0;
		flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD;
		if (!(sb->s_flags & MS_RDONLY)) {
			printk(KERN_INFO "ufstype=openstep is supported read-only\n");
			sb->s_flags |= MS_RDONLY;
		}
		break;
	
	case UFS_MOUNT_UFSTYPE_HP:
		UFSD(("ufstype=hp\n"))
		uspi->s_fsize = block_size = 1024;
		uspi->s_fmask = ~(1024 - 1);
		uspi->s_fshift = 10;
		uspi->s_sbsize = super_block_size = 2048;
		uspi->s_sbbase = 0;
		flags |= UFS_DE_OLD | UFS_UID_OLD | UFS_ST_OLD | UFS_CG_OLD;
		if (!(sb->s_flags & MS_RDONLY)) {
			printk(KERN_INFO "ufstype=hp is supported read-only\n");
			sb->s_flags |= MS_RDONLY;
 		}
 		break;
	default:
		printk("unknown ufstype\n");
		goto failed;
	}
	
again:	
	if (!sb_set_blocksize(sb, block_size)) {
		printk(KERN_ERR "UFS: failed to set blocksize\n");
		goto failed;
	}

	/*
	 * read ufs super block from device
	 */
	ubh = ubh_bread_uspi (uspi, sb, uspi->s_sbbase + UFS_SBLOCK/block_size, super_block_size);
	if (!ubh) 
		goto failed;
	
	usb1 = ubh_get_usb_first(USPI_UBH);
	usb2 = ubh_get_usb_second(USPI_UBH);
	usb3 = ubh_get_usb_third(USPI_UBH);

	/*
	 * Check ufs magic number
	 */
	switch (__constant_le32_to_cpu(usb3->fs_magic)) {
		case UFS_MAGIC:
		case UFS_MAGIC_LFN:
	        case UFS_MAGIC_FEA:
	        case UFS_MAGIC_4GB:
			sbi->s_bytesex = BYTESEX_LE;
			goto magic_found;
	}
	switch (__constant_be32_to_cpu(usb3->fs_magic)) {
		case UFS_MAGIC:
		case UFS_MAGIC_LFN:
	        case UFS_MAGIC_FEA:
	        case UFS_MAGIC_4GB:
			sbi->s_bytesex = BYTESEX_BE;
			goto magic_found;
	}

	if ((((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_NEXTSTEP) 
	  || ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_NEXTSTEP_CD) 
	  || ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_OPENSTEP)) 
	  && uspi->s_sbbase < 256) {
		ubh_brelse_uspi(uspi);
		ubh = NULL;
		uspi->s_sbbase += 8;
		goto again;
	}
	printk("ufs_read_super: bad magic number\n");
	goto failed;

magic_found:
	/*
	 * Check block and fragment sizes
	 */
	uspi->s_bsize = fs32_to_cpu(sb, usb1->fs_bsize);
	uspi->s_fsize = fs32_to_cpu(sb, usb1->fs_fsize);
	uspi->s_sbsize = fs32_to_cpu(sb, usb1->fs_sbsize);
	uspi->s_fmask = fs32_to_cpu(sb, usb1->fs_fmask);
	uspi->s_fshift = fs32_to_cpu(sb, usb1->fs_fshift);

	if (uspi->s_fsize & (uspi->s_fsize - 1)) {
		printk(KERN_ERR "ufs_read_super: fragment size %u is not a power of 2\n",
			uspi->s_fsize);
			goto failed;
	}
	if (uspi->s_fsize < 512) {
		printk(KERN_ERR "ufs_read_super: fragment size %u is too small\n",
			uspi->s_fsize);
		goto failed;
	}
	if (uspi->s_fsize > 4096) {
		printk(KERN_ERR "ufs_read_super: fragment size %u is too large\n",
			uspi->s_fsize);
		goto failed;
	}
	if (uspi->s_bsize & (uspi->s_bsize - 1)) {
		printk(KERN_ERR "ufs_read_super: block size %u is not a power of 2\n",
			uspi->s_bsize);
		goto failed;
	}
	if (uspi->s_bsize < 4096) {
		printk(KERN_ERR "ufs_read_super: block size %u is too small\n",
			uspi->s_bsize);
		goto failed;
	}
	if (uspi->s_bsize / uspi->s_fsize > 8) {
		printk(KERN_ERR "ufs_read_super: too many fragments per block (%u)\n",
			uspi->s_bsize / uspi->s_fsize);
		goto failed;
	}
	if (uspi->s_fsize != block_size || uspi->s_sbsize != super_block_size) {
		ubh_brelse_uspi(uspi);
		ubh = NULL;
		block_size = uspi->s_fsize;
		super_block_size = uspi->s_sbsize;
		UFSD(("another value of block_size or super_block_size %u, %u\n", block_size, super_block_size))
		goto again;
	}