X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_pmd_af_packet%2Frte_eth_af_packet.c;h=2ac50ba3130c1a9b805bb545d09f055f9c19f04e;hb=f14db469be8e6ac625353f577ad8fa0eec489e54;hp=d0fb3eb32e4486038f40770abed7be916bff8c3d;hpb=a3a03e13a6b2e33efeae2ae99a63159193981a7a;p=dpdk.git diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c index d0fb3eb32e..2ac50ba313 100644 --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c @@ -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++) { @@ -444,7 +442,8 @@ rte_pmd_init_internals(const char *name, struct tpacket_req *req; struct pkt_rx_queue *rx_queue; struct pkt_tx_queue *tx_queue; - int rc, qsockfd, tpver, discard; + int rc, tpver, discard; + int qsockfd = -1; unsigned int i, q, rdsize; int fanout_arg __rte_unused, bypass __rte_unused; @@ -481,6 +480,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 +607,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 +621,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 +650,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; @@ -676,14 +684,22 @@ error: rte_free(data); if (pci_dev) rte_free(pci_dev); - for (q = 0; q < nb_queues; q++) { - if ((*internals)->rx_queue[q].rd) - rte_free((*internals)->rx_queue[q].rd); - if ((*internals)->tx_queue[q].rd) - rte_free((*internals)->tx_queue[q].rd); - } - if (*internals) + 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) + rte_free((*internals)->tx_queue[q].rd); + if (((*internals)->rx_queue[q].sockfd != 0) && + ((*internals)->rx_queue[q].sockfd != qsockfd)) + close((*internals)->rx_queue[q].sockfd); + } rte_free(*internals); + } + if (qsockfd != -1) + close(qsockfd); return -1; } @@ -792,7 +808,7 @@ int rte_pmd_af_packet_devinit(const char *name, const char *params) { unsigned numa_node; - int ret; + int ret = 0; struct rte_kvargs *kvlist; int sockfd = -1; @@ -801,8 +817,10 @@ rte_pmd_af_packet_devinit(const char *name, const char *params) numa_node = rte_socket_id(); kvlist = rte_kvargs_parse(params, valid_arguments); - if (kvlist == NULL) - return -1; + if (kvlist == NULL) { + ret = -1; + goto exit; + } /* * If iface argument is passed we open the NICs and use them for @@ -813,16 +831,15 @@ rte_pmd_af_packet_devinit(const char *name, const char *params) ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG, &open_packet_iface, &sockfd); if (ret < 0) - return -1; + goto exit; } ret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist); close(sockfd); /* no longer needed */ - if (ret < 0) - return -1; - - return 0; +exit: + rte_kvargs_free(kvlist); + return ret; } static struct rte_driver pmd_af_packet_drv = {