ethdev: add device type
[dpdk.git] / lib / librte_pmd_af_packet / rte_eth_af_packet.c
index ad7242c..80e9bdf 100644 (file)
@@ -285,8 +285,6 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
        unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
        const struct pmd_internals *internal = dev->data->dev_private;
 
-       memset(igb_stats, 0, sizeof(*igb_stats));
-
        imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
                internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);
        for (i = 0; i < imax; i++) {
@@ -481,6 +479,11 @@ rte_pmd_init_internals(const char *name,
        if (*internals == NULL)
                goto error;
 
+       for (q = 0; q < nb_queues; q++) {
+               (*internals)->rx_queue[q].map = MAP_FAILED;
+               (*internals)->tx_queue[q].map = MAP_FAILED;
+       }
+
        req = &((*internals)->req);
 
        req->tp_block_size = blocksize;
@@ -603,6 +606,8 @@ rte_pmd_init_internals(const char *name,
                rdsize = req->tp_frame_nr * sizeof(*(rx_queue->rd));
 
                rx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
+               if (rx_queue->rd == NULL)
+                       goto error;
                for (i = 0; i < req->tp_frame_nr; ++i) {
                        rx_queue->rd[i].iov_base = rx_queue->map + (i * framesize);
                        rx_queue->rd[i].iov_len = req->tp_frame_size;
@@ -615,6 +620,8 @@ rte_pmd_init_internals(const char *name,
                tx_queue->map = rx_queue->map + req->tp_block_size * req->tp_block_nr;
 
                tx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
+               if (tx_queue->rd == NULL)
+                       goto error;
                for (i = 0; i < req->tp_frame_nr; ++i) {
                        tx_queue->rd[i].iov_base = tx_queue->map + (i * framesize);
                        tx_queue->rd[i].iov_len = req->tp_frame_size;
@@ -642,7 +649,7 @@ rte_pmd_init_internals(const char *name,
        }
 
        /* reserve an ethdev entry */
-       *eth_dev = rte_eth_dev_allocate(name);
+       *eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
        if (*eth_dev == NULL)
                goto error;
 
@@ -678,6 +685,8 @@ error:
                rte_free(pci_dev);
        if (*internals) {
                for (q = 0; q < nb_queues; q++) {
+                       munmap((*internals)->rx_queue[q].map,
+                              2 * req->tp_block_size * req->tp_block_nr);
                        if ((*internals)->rx_queue[q].rd)
                                rte_free((*internals)->rx_queue[q].rd);
                        if ((*internals)->tx_queue[q].rd)