Пример #1
0
static void fm10k_get_ethtool_stats(struct net_device *netdev,
				    struct ethtool_stats __always_unused *stats,
				    u64 *data)
{
	const int stat_count = sizeof(struct fm10k_queue_stats) / sizeof(u64);
	struct fm10k_intfc *interface = netdev_priv(netdev);
	struct net_device_stats *net_stats = &netdev->stats;
	char *p;
	int i, j;

	fm10k_update_stats(interface);

	for (i = 0; i < FM10K_NETDEV_STATS_LEN; i++) {
		p = (char *)net_stats + fm10k_gstrings_net_stats[i].stat_offset;
		*(data++) = (fm10k_gstrings_net_stats[i].sizeof_stat ==
			sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
	}

	for (i = 0; i < FM10K_GLOBAL_STATS_LEN; i++) {
		p = (char *)interface +
		    fm10k_gstrings_global_stats[i].stat_offset;
		*(data++) = (fm10k_gstrings_global_stats[i].sizeof_stat ==
			sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
	}

	if (interface->hw.mac.type != fm10k_mac_vf)
		for (i = 0; i < FM10K_PF_STATS_LEN; i++) {
			p = (char *)interface +
			    fm10k_gstrings_pf_stats[i].stat_offset;
			*(data++) = (fm10k_gstrings_pf_stats[i].sizeof_stat ==
				     sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
		}

	for (i = 0; i < interface->hw.mac.max_queues; i++) {
		struct fm10k_ring *ring;
		u64 *queue_stat;

		ring = interface->tx_ring[i];
		if (ring)
			queue_stat = (u64 *)&ring->stats;
		for (j = 0; j < stat_count; j++)
			*(data++) = ring ? queue_stat[j] : 0;

		ring = interface->rx_ring[i];
		if (ring)
			queue_stat = (u64 *)&ring->stats;
		for (j = 0; j < stat_count; j++)
			*(data++) = ring ? queue_stat[j] : 0;
	}
}
Пример #2
0
static void fm10k_get_ethtool_stats(struct net_device *netdev,
				    struct ethtool_stats __always_unused *stats,
				    u64 *data)
{
	struct fm10k_intfc *interface = netdev_priv(netdev);
	struct net_device_stats *net_stats = &netdev->stats;
	int i;

	fm10k_update_stats(interface);

	fm10k_add_ethtool_stats(&data, net_stats, fm10k_gstrings_net_stats,
				FM10K_NETDEV_STATS_LEN);

	fm10k_add_ethtool_stats(&data, interface, fm10k_gstrings_global_stats,
				FM10K_GLOBAL_STATS_LEN);

	fm10k_add_ethtool_stats(&data, &interface->hw.mbx,
				fm10k_gstrings_mbx_stats,
				FM10K_MBX_STATS_LEN);

	if (interface->hw.mac.type != fm10k_mac_vf) {
		fm10k_add_ethtool_stats(&data, interface,
					fm10k_gstrings_pf_stats,
					FM10K_PF_STATS_LEN);
	}

	for (i = 0; i < interface->hw.mac.max_queues; i++) {
		struct fm10k_ring *ring;

		ring = interface->tx_ring[i];
		fm10k_add_ethtool_stats(&data, ring,
					fm10k_gstrings_queue_stats,
					FM10K_QUEUE_STATS_LEN);

		ring = interface->rx_ring[i];
		fm10k_add_ethtool_stats(&data, ring,
					fm10k_gstrings_queue_stats,
					FM10K_QUEUE_STATS_LEN);
	}
}
static void fm10k_get_ethtool_stats(struct net_device *netdev,
				    struct ethtool_stats __always_unused *stats,
				    u64 *data)
{
	const int stat_count = sizeof(struct fm10k_queue_stats) / sizeof(u64);
	struct fm10k_intfc *interface = netdev_priv(netdev);
	struct fm10k_iov_data *iov_data = interface->iov_data;
	struct net_device_stats *net_stats = &netdev->stats;
	char *p;
	int i, j;

	fm10k_update_stats(interface);

	for (i = 0; i < FM10K_NETDEV_STATS_LEN; i++) {
		p = (char *)net_stats + fm10k_gstrings_net_stats[i].stat_offset;
		*(data++) = (fm10k_gstrings_net_stats[i].sizeof_stat ==
			sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
	}

	for (i = 0; i < FM10K_GLOBAL_STATS_LEN; i++) {
		p = (char *)interface +
		    fm10k_gstrings_global_stats[i].stat_offset;
		*(data++) = (fm10k_gstrings_global_stats[i].sizeof_stat ==
			sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
	}

	if (interface->flags & FM10K_FLAG_DEBUG_STATS) {
		for (i = 0; i < FM10K_DEBUG_STATS_LEN; i++) {
			p = (char *)interface + fm10k_gstrings_debug_stats[i].stat_offset;
			*(data++) = (fm10k_gstrings_debug_stats[i].sizeof_stat ==
				     sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
		}
	}

	for (i = 0; i < FM10K_MBX_STATS_LEN; i++) {
		p = (char *)&interface->hw.mbx + fm10k_gstrings_mbx_stats[i].stat_offset;
		*(data++) = (fm10k_gstrings_mbx_stats[i].sizeof_stat ==
			sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
	}

	if (interface->hw.mac.type != fm10k_mac_vf) {
		for (i = 0; i < FM10K_PF_STATS_LEN; i++) {
			p = (char *)interface +
			    fm10k_gstrings_pf_stats[i].stat_offset;
			*(data++) = (fm10k_gstrings_pf_stats[i].sizeof_stat ==
				     sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
		}
	}

	if ((interface->flags & FM10K_FLAG_DEBUG_STATS) && iov_data) {
		for (i = 0; i < iov_data->num_vfs; i++) {
			struct fm10k_vf_info *vf_info;
			vf_info = &iov_data->vf_info[i];

			/* skip stats if we don't have a vf info */
			if (!vf_info) {
				data += FM10K_MBX_STATS_LEN;
				continue;
			}

			for (j = 0; j < FM10K_MBX_STATS_LEN; j++) {
				p = (char *)&vf_info->mbx + fm10k_gstrings_mbx_stats[j].stat_offset;
				*(data++) = (fm10k_gstrings_mbx_stats[j].sizeof_stat ==
					     sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
			}
		}
	}

	for (i = 0; i < interface->hw.mac.max_queues; i++) {
		struct fm10k_ring *ring;
		u64 *queue_stat;

		ring = interface->tx_ring[i];
		if (ring)
			queue_stat = (u64 *)&ring->stats;
		for (j = 0; j < stat_count; j++)
			*(data++) = ring ? queue_stat[j] : 0;

		ring = interface->rx_ring[i];
		if (ring)
			queue_stat = (u64 *)&ring->stats;
		for (j = 0; j < stat_count; j++)
			*(data++) = ring ? queue_stat[j] : 0;
	}
}