X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fpcap%2Fpcap_ethdev.c;h=3566aea010532459b1436fdf070ed1e14fdb547b;hb=6065f4cdc31ba83e41688691b61f025c03edb1c6;hp=5ff7339e97c4b51daa8cb34a9562ecbcb2f1e820;hpb=436c089a528cbb834381eb908ec33bd0c9da6b92;p=dpdk.git diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index 5ff7339e97..3566aea010 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "pcap_osdep.h" @@ -50,6 +51,7 @@ struct queue_stat { volatile unsigned long pkts; volatile unsigned long bytes; volatile unsigned long err_pkts; + volatile unsigned long rx_nombuf; }; struct queue_missed_stat { @@ -140,11 +142,7 @@ static struct rte_eth_link pmd_link = { .link_autoneg = ETH_LINK_FIXED, }; -RTE_LOG_REGISTER(eth_pcap_logtype, pmd.net.pcap, NOTICE); - -#define PMD_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \ - "%s(): " fmt "\n", __func__, ##args) +RTE_LOG_REGISTER_DEFAULT(eth_pcap_logtype, NOTICE); static struct queue_missed_stat* queue_missed_stat_update(struct rte_eth_dev *dev, unsigned int qid) @@ -300,8 +298,10 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) break; mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool); - if (unlikely(mbuf == NULL)) + if (unlikely(mbuf == NULL)) { + pcap_q->rx_stat.rx_nombuf++; break; + } if (header.caplen <= rte_pktmbuf_tailroom(mbuf)) { /* pcap packet will fit in the mbuf, can copy it */ @@ -314,6 +314,7 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf, packet, header.caplen) == -1)) { + pcap_q->rx_stat.err_pkts++; rte_pktmbuf_free(mbuf); break; } @@ -746,6 +747,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) unsigned int i; unsigned long rx_packets_total = 0, rx_bytes_total = 0; unsigned long rx_missed_total = 0; + unsigned long rx_nombuf_total = 0, rx_err_total = 0; unsigned long tx_packets_total = 0, tx_bytes_total = 0; unsigned long tx_packets_err_total = 0; const struct pmd_internals *internal = dev->data->dev_private; @@ -754,6 +756,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) i < dev->data->nb_rx_queues; i++) { stats->q_ipackets[i] = internal->rx_queue[i].rx_stat.pkts; stats->q_ibytes[i] = internal->rx_queue[i].rx_stat.bytes; + rx_nombuf_total += internal->rx_queue[i].rx_stat.rx_nombuf; + rx_err_total += internal->rx_queue[i].rx_stat.err_pkts; rx_packets_total += stats->q_ipackets[i]; rx_bytes_total += stats->q_ibytes[i]; rx_missed_total += queue_missed_stat_get(dev, i); @@ -771,6 +775,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->ipackets = rx_packets_total; stats->ibytes = rx_bytes_total; stats->imissed = rx_missed_total; + stats->ierrors = rx_err_total; + stats->rx_nombuf = rx_nombuf_total; stats->opackets = tx_packets_total; stats->obytes = tx_bytes_total; stats->oerrors = tx_packets_err_total; @@ -787,6 +793,8 @@ eth_stats_reset(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { internal->rx_queue[i].rx_stat.pkts = 0; internal->rx_queue[i].rx_stat.bytes = 0; + internal->rx_queue[i].rx_stat.err_pkts = 0; + internal->rx_queue[i].rx_stat.rx_nombuf = 0; queue_missed_stat_reset(dev, i); } @@ -1365,6 +1373,33 @@ eth_from_pcaps(struct rte_vdev_device *vdev, return 0; } +static void +eth_release_pcaps(struct pmd_devargs *pcaps, + struct pmd_devargs *dumpers, + int single_iface) +{ + unsigned int i; + + if (single_iface) { + if (pcaps->queue[0].pcap) + pcap_close(pcaps->queue[0].pcap); + return; + } + + for (i = 0; i < dumpers->num_of_queue; i++) { + if (dumpers->queue[i].dumper) + pcap_dump_close(dumpers->queue[i].dumper); + + if (dumpers->queue[i].pcap) + pcap_close(dumpers->queue[i].pcap); + } + + for (i = 0; i < pcaps->num_of_queue; i++) { + if (pcaps->queue[i].pcap) + pcap_close(pcaps->queue[i].pcap); + } +} + static int pmd_pcap_probe(struct rte_vdev_device *dev) { @@ -1585,6 +1620,9 @@ create_eth: free_kvlist: rte_kvargs_free(kvlist); + if (ret < 0) + eth_release_pcaps(&pcaps, &dumpers, devargs_all.single_iface); + return ret; }