Beispiel #1
0
static int
test_stats_reset(void)
{
	struct rte_eth_stats stats;
	struct rte_mbuf buf, *pbuf = &buf;

	printf("Testing ring PMD stats reset\n");

	rte_eth_stats_reset(RXTX_PORT);

	/* check stats of RXTX port, should all be zero */
	rte_eth_stats_get(RXTX_PORT, &stats);
	if (stats.ipackets != 0 || stats.opackets != 0 ||
			stats.ibytes != 0 || stats.obytes != 0 ||
			stats.ierrors != 0 || stats.oerrors != 0) {
		printf("Error: RXTX port stats are not zero\n");
		return -1;
	}

	/* send and receive 1 packet and check for stats update */
	if (rte_eth_tx_burst(RXTX_PORT, 0, &pbuf, 1) != 1) {
		printf("Error sending packet to RXTX port\n");
		return -1;
	}

	if (rte_eth_rx_burst(RXTX_PORT, 0, &pbuf, 1) != 1) {
		printf("Error receiving packet from RXTX port\n");
		return -1;
	}

	rte_eth_stats_get(RXTX_PORT, &stats);
	if (stats.ipackets != 1 || stats.opackets != 1 ||
			stats.ibytes != 0 || stats.obytes != 0 ||
			stats.ierrors != 0 || stats.oerrors != 0) {
		printf("Error: RXTX port stats are not as expected\n");
		return -1;
	}

	rte_eth_stats_reset(RXTX_PORT);

	/* check stats of RXTX port, should all be zero */
	rte_eth_stats_get(RXTX_PORT, &stats);
	if (stats.ipackets != 0 || stats.opackets != 0 ||
			stats.ibytes != 0 || stats.obytes != 0 ||
			stats.ierrors != 0 || stats.oerrors != 0) {
		printf("Error: RXTX port stats are not zero\n");
		return -1;
	}

	return 0;
}
Beispiel #2
0
static void
nic_stats_clear(uint8_t port_id)
{
	printf("\n Clearing NIC stats for port %d\n", port_id);
	rte_eth_stats_reset(port_id);
	printf("\n  NIC statistics for port %d cleared\n", port_id);
}
Beispiel #3
0
/**
 * @brief           Reset device statistics data on HW
 * 
 * @param devId     uint8_t, ID of DPDK device
 */
void DPDKAdapter::resetDevStats(uint8_t devId)
{
    if(devId > RTE_MAX_ETHPORTS)
    {
        qCritical("Device ID is out of range");
        return;
    }

    rte_eth_stats_reset(devId);
}
Beispiel #4
0
void 
rw_piot_reset_link_stats(rw_piot_api_handle_t api_handle)
{
  rw_piot_device_t *rw_piot_dev = RWPIOT_GET_DEVICE(api_handle);
  ASSERT(RWPIOT_VALID_DEVICE(rw_piot_dev));
  if (NULL == rw_piot_dev) {
    RW_PIOT_LOG(RTE_LOG_ERR, "PIOT Could not find device by handle or invalid input param\n");
    return;
  }
  rte_eth_stats_reset(rw_piot_dev->rte_port_id);
  return;
}
Beispiel #5
0
static inline void app_lcore_io_tx_bw (struct app_lcore_params_io *lp, uint32_t bsz_wr) {
	uint32_t i;
	uint32_t k;

	for (i = 0; i < lp->tx.n_nic_queues; i++) {
		uint8_t port  = lp->tx.nic_queues[i].port;
		uint8_t queue = lp->tx.nic_queues[i].queue;
		uint32_t n_mbufs, n_pkts;
		n_mbufs = bsz_wr;

		for (k = 0; k < n_mbufs; k++) {
			lp->tx.mbuf_out[port].array[k] = rte_ctrlmbuf_alloc (app.pools[0]);
			if (lp->tx.mbuf_out[port].array[k] == NULL) {
				n_mbufs = k;
				break;
			}

			lp->tx.mbuf_out[port].array[k]->pkt_len  = sndpktlen;
			lp->tx.mbuf_out[port].array[k]->data_len = sndpktlen;
			lp->tx.mbuf_out[port].array[k]->port     = port;

			memcpy (rte_ctrlmbuf_data (lp->tx.mbuf_out[port].array[k]), icmppkt, icmppktlen);
		}

		n_pkts = rte_eth_tx_burst (port, queue, lp->tx.mbuf_out[port].array, n_mbufs);

#if APP_STATS
		lp->tx.nic_queues_iters[i]++;
		lp->tx.nic_queues_count[i] += n_mbufs;
		if (unlikely (lp->tx.nic_queues_iters[i] == APP_STATS)) {
			struct rte_eth_stats stats;
			struct timeval start_ewr, end_ewr;

			rte_eth_stats_get (port, &stats);
			gettimeofday (&lp->tx.end_ewr, NULL);

			start_ewr = lp->tx.start_ewr;
			end_ewr   = lp->tx.end_ewr;

			if (queue == 0) {
				printf (
				    "NIC TX port %u: drop ratio = %.2f (%lu/%lu) usefull-speed: %lf Gbps, "
				    "link-speed: %lf Gbps (%.1lf pkts/s)\n",
				    (unsigned)port,
				    (double)stats.oerrors / (double)(stats.oerrors + stats.opackets),
				    (uint64_t)stats.opackets,
				    (uint64_t)stats.oerrors,
				    (stats.obytes / (((end_ewr.tv_sec * 1000000. + end_ewr.tv_usec) -
				                      (start_ewr.tv_sec * 1000000. + start_ewr.tv_usec)) /
				                     1000000.)) /
				        (1000 * 1000 * 1000. / 8.),
				    (((stats.obytes) + stats.opackets * (/*4crc+8prelud+12ifg*/ (8 + 12))) /
				     (((end_ewr.tv_sec * 1000000. + end_ewr.tv_usec) -
				       (start_ewr.tv_sec * 1000000. + start_ewr.tv_usec)) /
				      1000000.)) /
				        (1000 * 1000 * 1000. / 8.),
				    stats.opackets / (((end_ewr.tv_sec * 1000000. + end_ewr.tv_usec) -
				                       (start_ewr.tv_sec * 1000000. + start_ewr.tv_usec)) /
				                      1000000.));

				rte_eth_stats_reset (port);
				lp->tx.start_ewr = end_ewr;  // Updating start
			}

			lp->tx.nic_queues_iters[i] = 0;
			lp->tx.nic_queues_count[i] = 0;
		}
#endif

		if (unlikely (n_pkts < n_mbufs)) {
			for (k = n_pkts; k < n_mbufs; k++) {
				struct rte_mbuf *pkt_to_free = lp->tx.mbuf_out[port].array[k];
				rte_ctrlmbuf_free (pkt_to_free);
			}
		}
	}
}
Beispiel #6
0
static inline void app_lcore_io_rx_bw (struct app_lcore_params_io *lp, uint32_t bsz_rd) {
	uint32_t i;

	for (i = 0; i < lp->rx.n_nic_queues; i++) {
		uint8_t port  = lp->rx.nic_queues[i].port;
		uint8_t queue = lp->rx.nic_queues[i].queue;
		uint32_t n_mbufs, j;

		n_mbufs = rte_eth_rx_burst (port, queue, lp->rx.mbuf_in.array, (uint16_t)bsz_rd);

		if (unlikely (n_mbufs == 0)) {
			continue;
		}

#if APP_STATS
		lp->rx.nic_queues_iters[i]++;
		lp->rx.nic_queues_count[i] += n_mbufs;
		if (unlikely (lp->rx.nic_queues_iters[i] == APP_STATS * 10)) {
			struct rte_eth_stats stats;
			struct timeval start_ewr, end_ewr;

			rte_eth_stats_get (port, &stats);
			gettimeofday (&lp->rx.end_ewr, NULL);

			start_ewr = lp->rx.start_ewr;
			end_ewr   = lp->rx.end_ewr;

#ifdef QUEUE_STATS
			if (queue == 0) {
#endif
				printf ("NIC port %u: drop ratio = %.2f (%lu/%lu) speed: %lf Gbps (%.1lf pkts/s)\n",
				        (unsigned)port,
				        (double)(stats.ierrors + stats.imissed) /
				            (double)((stats.ierrors + stats.imissed) + stats.ipackets),
				        (uint64_t)stats.ipackets,
				        (uint64_t) (stats.ierrors + stats.imissed),
				        (((stats.ibytes) + stats.ipackets * (/*4crc+8prelud+12ifg*/ (8 + 12))) /
				         (((end_ewr.tv_sec * 1000000. + end_ewr.tv_usec) -
				           (start_ewr.tv_sec * 1000000. + start_ewr.tv_usec)) /
				          1000000.)) /
				            (1000 * 1000 * 1000. / 8.),
				        stats.ipackets / (((end_ewr.tv_sec * 1000000. + end_ewr.tv_usec) -
				                           (start_ewr.tv_sec * 1000000. + start_ewr.tv_usec)) /
				                          1000000.));
#ifdef QUEUE_STATS
			}
			printf (
			    "NIC port %u:%u: drop ratio = %.2f (%u/%u) speed %.1lf pkts/s\n",
			    (unsigned)port,
			    queue,
			    (double)stats.ierrors / (double)(stats.ierrors + lp->rx.nic_queues_count[i]),
			    (uint32_t)lp->rx.nic_queues_count[i],
			    (uint32_t)stats.ierrors,
			    lp->rx.nic_queues_count[i] / (((end_ewr.tv_sec * 1000000. + end_ewr.tv_usec) -
			                                   (start_ewr.tv_sec * 1000000. + start_ewr.tv_usec)) /
			                                  1000000.));
#endif
			lp->rx.nic_queues_iters[i] = 0;
			lp->rx.nic_queues_count[i] = 0;

#ifdef QUEUE_STATS
			if (queue == 0)
#endif
				rte_eth_stats_reset (port);

#ifdef QUEUE_STATS
			if (queue == 0)
#endif
				lp->rx.start_ewr = end_ewr;  // Updating start
		}
#endif

		for (j = 0; j < n_mbufs; j++) {
			struct rte_mbuf *pkt = lp->rx.mbuf_in.array[j];
			rte_pktmbuf_free (pkt);
		}
	}
}
void
nic_stats_clear(struct cmdline *cl, portid_t port_id)
{
	rte_eth_stats_reset(port_id);
	cmdline_printf(cl, "\n  NIC statistics for port %d cleared\n", port_id);
}