xen: allow determining DOM0 at runtime
[dpdk.git] / lib / librte_ether / rte_ethdev.c
index 1b73f29..0e41387 100644 (file)
@@ -1515,7 +1515,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
        dev = &rte_eth_devices[port_id];
 
        /* Return generic statistics */
-       count = RTE_NB_STATS;
+       count = RTE_NB_STATS + (dev->data->nb_rx_queues * RTE_NB_RXQ_STATS) +
+               (dev->data->nb_tx_queues * RTE_NB_TXQ_STATS);
 
        /* implemented by the driver */
        if (dev->dev_ops->xstats_get != NULL) {
@@ -1527,9 +1528,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 
                if (xcount < 0)
                        return xcount;
-       } else {
-               count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
-               count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
        }
 
        if (n < count + xcount)
@@ -1549,10 +1547,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
                xstats[count++].value = val;
        }
 
-       /* if xstats_get() is implemented by the PMD, the Q stats are done */
-       if (dev->dev_ops->xstats_get != NULL)
-               return count + xcount;
-
        /* per-rxq stats */
        for (q = 0; q < dev->data->nb_rx_queues; q++) {
                for (i = 0; i < RTE_NB_RXQ_STATS; i++) {
@@ -2700,6 +2694,30 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
        return 0;
 }
 
+const struct rte_memzone *
+rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
+                        uint16_t queue_id, size_t size, unsigned align,
+                        int socket_id)
+{
+       char z_name[RTE_MEMZONE_NAMESIZE];
+       const struct rte_memzone *mz;
+
+       snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
+                dev->driver->pci_drv.name, ring_name,
+                dev->data->port_id, queue_id);
+
+       mz = rte_memzone_lookup(z_name);
+       if (mz)
+               return mz;
+
+       if (is_xen_dom0_supported())
+               return rte_memzone_reserve_bounded(z_name, size, socket_id,
+                                                  0, align, RTE_PGSIZE_2M);
+       else
+               return rte_memzone_reserve_aligned(z_name, size, socket_id,
+                                                  0, align);
+}
+
 int
 rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
                          int epfd, int op, void *data)