linux/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
/** Fill in hardware counters, as returned by MC.
 */
Fill in hardware counters, as returned by MC.
Fill in hardware counters as returned by MC .
static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev,
					struct ethtool_stats *stats,
					u64 *data)
{
	int i = 0;
	int j, k, err;
	int num_cnt;
	union dpni_statistics dpni_stats;
	u64 cdan = 0;
	u64 portal_busy = 0, pull_err = 0;
	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
	struct dpaa2_eth_drv_stats *extras;
	struct dpaa2_eth_ch_stats *ch_stats;
	memset(data, 0,
	       sizeof(u64) * (DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS));
	for (j = 0; j <= 2; j++) {
		err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token,
					  j, &dpni_stats);
		if (err != 0)
			netdev_warn(net_dev, "dpni_get_stats(%d) failed\n", j);
		switch (j) {
		case 0:
			num_cnt = sizeof(dpni_stats.page_0) / sizeof(u64);
			break;
		case 1:
			num_cnt = sizeof(dpni_stats.page_1) / sizeof(u64);
			break;
		case 2:
			num_cnt = sizeof(dpni_stats.page_2) / sizeof(u64);
			break;
		}
		for (k = 0; k < num_cnt; k++)
			*(data + i++) = dpni_stats.raw.counter[k];
	}
	for_each_online_cpu(k) {
		extras = per_cpu_ptr(priv->percpu_extras, k);
		for (j = 0; j < sizeof(*extras) / sizeof(__u64); j++)
			*((__u64 *)data + i + j) += *((__u64 *)extras + j);
	}
	i += j;
	for (j = 0; j < priv->num_channels; j++) {
		ch_stats = &priv->channel[j]->stats;
		cdan += ch_stats->cdan;
		portal_busy += ch_stats->dequeue_portal_busy;
		pull_err += ch_stats->pull_err;
	}
	*(data + i++) = portal_busy;
	*(data + i++) = pull_err;
	*(data + i++) = cdan;
}
static void dpaa2_eth_get_ethtool_stats ( struct net_device * net_dev , struct ethtool_stats * stats , u64 * data ) { int i = 0 ; int j , k , err ; int num_cnt ; union dpni_statistics dpni_stats ; u64 cdan = 0 ; u64 portal_busy = 0 , pull_err = 0 ; struct dpaa2_eth_priv * priv = netdev_priv ( net_dev ) ; struct dpaa2_eth_drv_stats * extras ; struct dpaa2_eth_ch_stats * ch_stats ; memset ( data , 0 , sizeof ( u64 ) * ( DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS ) ) ; for ( j = 0 ; j <= 2 ; j ++ ) { err = dpni_get_statistics ( priv -> mc_io , 0 , priv -> mc_token , j , & dpni_stats ) ; if ( err != 0 ) netdev_warn ( net_dev , " \n " , j ) ; switch ( j ) { case 0 : num_cnt = sizeof ( dpni_stats . page_0 ) / sizeof ( u64 ) ; break ; case 1 : num_cnt = sizeof ( dpni_stats . page_1 ) / sizeof ( u64 ) ; break ; case 2 : num_cnt = sizeof ( dpni_stats . page_2 ) / sizeof ( u64 ) ; break ; } for ( k = 0 ; k < num_cnt ; k ++ ) * ( data + i ++ ) = dpni_stats . raw . counter [ k ] ; } for_each_online_cpu ( k ) { extras = per_cpu_ptr ( priv -> percpu_extras , k ) ; for ( j = 0 ; j < sizeof ( * extras ) / sizeof ( __u64 ) ; j ++ ) * ( ( __u64 * ) data + i + j ) += * ( ( __u64 * ) extras + j ) ; } i += j ; for ( j = 0 ; j < priv -> num_channels ; j ++ ) { ch_stats = & priv -> channel [ j ] -> stats ; cdan += ch_stats -> cdan ; portal_busy += ch_stats -> dequeue_portal_busy ; pull_err += ch_stats -> pull_err ; } * ( data + i ++ ) = portal_busy ; * ( data + i ++ ) = pull_err ; * ( data + i ++ ) = cdan ; }
Fill in hardware counters, as returned by MC.
Fill in hardware counters as returned by MC .
/* Print standard counters, from DPNI statistics */ /* Print per-cpu extra stats */