diff mbox series

[ovs-dev,v11,2/3] netdev-dpdk : Detailed packet drop statistics

Message ID 20191029145006.29048-2-sriram.v@altencalsoftlabs.com
State Accepted
Delegated to: Ilya Maximets
Headers show
Series [ovs-dev,v11,1/3] netdev-dpdk: Reuse vhost function for dpdk ETH custom stats. | expand

Commit Message

Li,Rongqing via dev Oct. 29, 2019, 2:50 p.m. UTC
OVS may be unable to transmit packets for multiple reasons on
the userspace datapath and today there is a single counter to
track packets dropped due to any of those reasons. This patch
adds custom software stats for the different reasons packets
may be dropped during tx/rx on the userspace datapath in OVS.

- MTU drops : drops that occur due to a too large packet size
- Qos drops : drops that occur due to egress/ingress QOS
- Tx failures: drops as returned by the DPDK PMD send function

Note that the reason for tx failures is not specified in OVS.
In practice for vhost ports it is most common that tx failures
are because there are not enough available descriptors,
which is usually caused by misconfiguration of the guest queues
and/or because the guest is not consuming packets fast enough
from the queues.

These counters are displayed along with other stats in
"ovs-vsctl get interface <iface> statistics" command and are
available for dpdk and vhostuser/vhostuserclient ports.

Also the existing "tx_retries" counter for vhost ports has been
renamed to "ovs_tx_retries", so that all the custom statistics
that OVS accumulates itself will have the prefix "ovs_". This
will prevent any custom stats names overlapping with
driver/HW stats.

Signed-off-by: Sriram Vatala <sriram.v@altencalsoftlabs.com>
---
 Documentation/topics/dpdk/bridge.rst     |  6 ++
 Documentation/topics/dpdk/vhost-user.rst |  2 +-
 lib/netdev-dpdk.c                        | 82 +++++++++++++++++++-----
 3 files changed, 72 insertions(+), 18 deletions(-)

Comments

Ilya Maximets Nov. 10, 2019, 11:20 p.m. UTC | #1
On 29.10.2019 15:50, Sriram Vatala wrote:> @@ -2388,12 +2412,16 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>           }
>       } while (cnt && (retries++ < max_retries));
>   
> +    tx_failure = cnt;
>       rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
>   
>       rte_spinlock_lock(&dev->stats_lock);
>       netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
>                                            cnt + dropped);
> -    dev->tx_retries += MIN(retries, max_retries);
> +    sw_stats->tx_retries += MIN(retries, max_retries);
> +    sw_stats->tx_failure_drops += tx_failure;
> +    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
> +    sw_stats->tx_qos_drops += qos_drops;

Kevin pointed to this part of code in hope that we can move this to
a separate function and reuse in his review for v9.  This code catches
my eyes too.  I don't think that we can reuse this part, at least this
will be not very efficient in current situation (clearing of the unused
fields in a stats structure will be probably needed before calling such
a common function, but ETH tx uses only half of the struct).

But there is another thing here.  We already have special functions
for vhost tx/rx counters.  And it looks strange when we're not using
these functions to update tx/rx failure counters.

Suggesting following incremental.
Kevin, Sriram, please, share your thoughts.

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 3cb7023a8..02120a379 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2169,16 +2169,18 @@ netdev_dpdk_vhost_update_rx_size_counters(struct netdev_stats *stats,
  }
  
  static inline void
-netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,
+netdev_dpdk_vhost_update_rx_counters(struct netdev_dpdk *dev,
                                       struct dp_packet **packets, int count,
-                                     int dropped)
+                                     int qos_drops)
  {
-    int i;
-    unsigned int packet_size;
+    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
+    struct netdev_stats *stats = &dev->stats;
      struct dp_packet *packet;
+    unsigned int packet_size;
+    int i;
  
      stats->rx_packets += count;
-    stats->rx_dropped += dropped;
+    stats->rx_dropped += qos_drops;
      for (i = 0; i < count; i++) {
          packet = packets[i];
          packet_size = dp_packet_size(packet);
@@ -2201,6 +2203,8 @@ netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,
  
          stats->rx_bytes += packet_size;
      }
+
+    sw_stats->rx_qos_drops += qos_drops;
  }
  
  /*
@@ -2213,7 +2217,7 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
      struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
      struct ingress_policer *policer = netdev_dpdk_get_ingress_policer(dev);
      uint16_t nb_rx = 0;
-    uint16_t dropped = 0;
+    uint16_t qos_drops = 0;
      int qid = rxq->queue_id * VIRTIO_QNUM + VIRTIO_TXQ;
      int vid = netdev_dpdk_get_vid(dev);
  
@@ -2240,17 +2244,16 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
      }
  
      if (policer) {
-        dropped = nb_rx;
+        qos_drops = nb_rx;
          nb_rx = ingress_policer_run(policer,
                                      (struct rte_mbuf **) batch->packets,
                                      nb_rx, true);
-        dropped -= nb_rx;
+        qos_drops -= nb_rx;
      }
  
      rte_spinlock_lock(&dev->stats_lock);
-    netdev_dpdk_vhost_update_rx_counters(&dev->stats, batch->packets,
-                                         nb_rx, dropped);
-    dev->sw_stats->rx_qos_drops += dropped;
+    netdev_dpdk_vhost_update_rx_counters(dev, batch->packets,
+                                         nb_rx, qos_drops);
      rte_spinlock_unlock(&dev->stats_lock);
  
      batch->count = nb_rx;
@@ -2360,13 +2363,18 @@ netdev_dpdk_filter_packet_len(struct netdev_dpdk *dev, struct rte_mbuf **pkts,
  }
  
  static inline void
-netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats,
+netdev_dpdk_vhost_update_tx_counters(struct netdev_dpdk *dev,
                                       struct dp_packet **packets,
                                       int attempted,
-                                     int dropped)
+                                     struct netdev_dpdk_sw_stats *sw_stats_add)
  {
-    int i;
+    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
+    int dropped = sw_stats_add->tx_mtu_exceeded_drops +
+                  sw_stats_add->tx_qos_drops +
+                  sw_stats_add->tx_failure_drops;
+    struct netdev_stats *stats = &dev->stats;
      int sent = attempted - dropped;
+    int i;
  
      stats->tx_packets += sent;
      stats->tx_dropped += dropped;
@@ -2374,6 +2382,11 @@ netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats,
      for (i = 0; i < sent; i++) {
          stats->tx_bytes += dp_packet_size(packets[i]);
      }
+
+    sw_stats->tx_retries            += sw_stats_add->tx_retries;
+    sw_stats->tx_failure_drops      += sw_stats_add->tx_failure_drops;
+    sw_stats->tx_mtu_exceeded_drops += sw_stats_add->tx_mtu_exceeded_drops;
+    sw_stats->tx_qos_drops          += sw_stats_add->tx_qos_drops;
  }
  
  static void
@@ -2382,12 +2395,9 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
  {
      struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
      struct rte_mbuf **cur_pkts = (struct rte_mbuf **) pkts;
-    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
-    unsigned int total_pkts = cnt;
-    unsigned int dropped = 0;
-    unsigned int tx_failure;
-    unsigned int mtu_drops;
-    unsigned int qos_drops;
+    struct netdev_dpdk_sw_stats sw_stats_add;
+    unsigned int n_packets_to_free = cnt;
+    unsigned int total_packets = cnt;
      int i, retries = 0;
      int max_retries = VHOST_ENQ_RETRY_MIN;
      int vid = netdev_dpdk_get_vid(dev);
@@ -2408,12 +2418,14 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
      }
  
      cnt = netdev_dpdk_filter_packet_len(dev, cur_pkts, cnt);
-    mtu_drops = total_pkts - cnt;
-    qos_drops = cnt;
+    sw_stats_add.tx_mtu_exceeded_drops = total_packets - cnt;
+
      /* Check has QoS has been configured for the netdev */
+    sw_stats_add.tx_qos_drops = cnt;
      cnt = netdev_dpdk_qos_run(dev, cur_pkts, cnt, true);
-    qos_drops -= cnt;
-    dropped = qos_drops + mtu_drops;
+    sw_stats_add.tx_qos_drops -= cnt;
+
+    n_packets_to_free = cnt;
  
      do {
          int vhost_qid = qid * VIRTIO_QNUM + VIRTIO_RXQ;
@@ -2438,20 +2450,18 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
          }
      } while (cnt && (retries++ < max_retries));
  
-    tx_failure = cnt;
      rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
  
+    sw_stats_add.tx_failure_drops = cnt;
+    sw_stats_add.tx_retries = MIN(retries, max_retries);
+
      rte_spinlock_lock(&dev->stats_lock);
-    netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
-                                         cnt + dropped);
-    sw_stats->tx_retries += MIN(retries, max_retries);
-    sw_stats->tx_failure_drops += tx_failure;
-    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
-    sw_stats->tx_qos_drops += qos_drops;
+    netdev_dpdk_vhost_update_tx_counters(dev, pkts, total_packets,
+                                         &sw_stats_add);
      rte_spinlock_unlock(&dev->stats_lock);
  
  out:
-    for (i = 0; i < total_pkts - dropped; i++) {
+    for (i = 0; i < n_packets_to_free; i++) {
          dp_packet_delete(pkts[i]);
      }
  }
---

Best regards, Ilya Maximets.
Ilya Maximets Nov. 10, 2019, 11:44 p.m. UTC | #2
Sorry if you've received incremental patch with shifted lines.
Thunderbird behaves weirdly.  For some reason it adds a single
space for every line that starts with a space.  I'm not sure
how to fix that.  I could re-send incremental patch with some
different tool (git-send-email) if needed.

   Test. (this line should be prefixed with exactly 2 spaces.)

Best regards, Ilya Maximets.
Ilya Maximets Nov. 11, 2019, 12:13 a.m. UTC | #3
On 11.11.2019 0:44, Ilya Maximets wrote:
> Sorry if you've received incremental patch with shifted lines.
> Thunderbird behaves weirdly.  For some reason it adds a single
> space for every line that starts with a space.  I'm not sure
> how to fix that.  I could re-send incremental patch with some
> different tool (git-send-email) if needed.

It looks like I found the reason.  If someone will ever catch
the same issue, disable 'mailnews.send_plaintext_flowed' in
thunderbird config editor.

Re-sending the incremental:

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 3cb7023a8..02120a379 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2169,16 +2169,18 @@ netdev_dpdk_vhost_update_rx_size_counters(struct netdev_stats *stats,
 }
 
 static inline void
-netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,
+netdev_dpdk_vhost_update_rx_counters(struct netdev_dpdk *dev,
                                      struct dp_packet **packets, int count,
-                                     int dropped)
+                                     int qos_drops)
 {
-    int i;
-    unsigned int packet_size;
+    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
+    struct netdev_stats *stats = &dev->stats;
     struct dp_packet *packet;
+    unsigned int packet_size;
+    int i;
 
     stats->rx_packets += count;
-    stats->rx_dropped += dropped;
+    stats->rx_dropped += qos_drops;
     for (i = 0; i < count; i++) {
         packet = packets[i];
         packet_size = dp_packet_size(packet);
@@ -2201,6 +2203,8 @@ netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,
 
         stats->rx_bytes += packet_size;
     }
+
+    sw_stats->rx_qos_drops += qos_drops;
 }
 
 /*
@@ -2213,7 +2217,7 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
     struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
     struct ingress_policer *policer = netdev_dpdk_get_ingress_policer(dev);
     uint16_t nb_rx = 0;
-    uint16_t dropped = 0;
+    uint16_t qos_drops = 0;
     int qid = rxq->queue_id * VIRTIO_QNUM + VIRTIO_TXQ;
     int vid = netdev_dpdk_get_vid(dev);
 
@@ -2240,17 +2244,16 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
     }
 
     if (policer) {
-        dropped = nb_rx;
+        qos_drops = nb_rx;
         nb_rx = ingress_policer_run(policer,
                                     (struct rte_mbuf **) batch->packets,
                                     nb_rx, true);
-        dropped -= nb_rx;
+        qos_drops -= nb_rx;
     }
 
     rte_spinlock_lock(&dev->stats_lock);
-    netdev_dpdk_vhost_update_rx_counters(&dev->stats, batch->packets,
-                                         nb_rx, dropped);
-    dev->sw_stats->rx_qos_drops += dropped;
+    netdev_dpdk_vhost_update_rx_counters(dev, batch->packets,
+                                         nb_rx, qos_drops);
     rte_spinlock_unlock(&dev->stats_lock);
 
     batch->count = nb_rx;
@@ -2360,13 +2363,18 @@ netdev_dpdk_filter_packet_len(struct netdev_dpdk *dev, struct rte_mbuf **pkts,
 }
 
 static inline void
-netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats,
+netdev_dpdk_vhost_update_tx_counters(struct netdev_dpdk *dev,
                                      struct dp_packet **packets,
                                      int attempted,
-                                     int dropped)
+                                     struct netdev_dpdk_sw_stats *sw_stats_add)
 {
-    int i;
+    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
+    int dropped = sw_stats_add->tx_mtu_exceeded_drops +
+                  sw_stats_add->tx_qos_drops +
+                  sw_stats_add->tx_failure_drops;
+    struct netdev_stats *stats = &dev->stats;
     int sent = attempted - dropped;
+    int i;
 
     stats->tx_packets += sent;
     stats->tx_dropped += dropped;
@@ -2374,6 +2382,11 @@ netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats,
     for (i = 0; i < sent; i++) {
         stats->tx_bytes += dp_packet_size(packets[i]);
     }
+
+    sw_stats->tx_retries            += sw_stats_add->tx_retries;
+    sw_stats->tx_failure_drops      += sw_stats_add->tx_failure_drops;
+    sw_stats->tx_mtu_exceeded_drops += sw_stats_add->tx_mtu_exceeded_drops;
+    sw_stats->tx_qos_drops          += sw_stats_add->tx_qos_drops;
 }
 
 static void
@@ -2382,12 +2395,9 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
 {
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
     struct rte_mbuf **cur_pkts = (struct rte_mbuf **) pkts;
-    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
-    unsigned int total_pkts = cnt;
-    unsigned int dropped = 0;
-    unsigned int tx_failure;
-    unsigned int mtu_drops;
-    unsigned int qos_drops;
+    struct netdev_dpdk_sw_stats sw_stats_add;
+    unsigned int n_packets_to_free = cnt;
+    unsigned int total_packets = cnt;
     int i, retries = 0;
     int max_retries = VHOST_ENQ_RETRY_MIN;
     int vid = netdev_dpdk_get_vid(dev);
@@ -2408,12 +2418,14 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
     }
 
     cnt = netdev_dpdk_filter_packet_len(dev, cur_pkts, cnt);
-    mtu_drops = total_pkts - cnt;
-    qos_drops = cnt;
+    sw_stats_add.tx_mtu_exceeded_drops = total_packets - cnt;
+
     /* Check has QoS has been configured for the netdev */
+    sw_stats_add.tx_qos_drops = cnt;
     cnt = netdev_dpdk_qos_run(dev, cur_pkts, cnt, true);
-    qos_drops -= cnt;
-    dropped = qos_drops + mtu_drops;
+    sw_stats_add.tx_qos_drops -= cnt;
+
+    n_packets_to_free = cnt;
 
     do {
         int vhost_qid = qid * VIRTIO_QNUM + VIRTIO_RXQ;
@@ -2438,20 +2450,18 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
         }
     } while (cnt && (retries++ < max_retries));
 
-    tx_failure = cnt;
     rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
 
+    sw_stats_add.tx_failure_drops = cnt;
+    sw_stats_add.tx_retries = MIN(retries, max_retries);
+
     rte_spinlock_lock(&dev->stats_lock);
-    netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
-                                         cnt + dropped);
-    sw_stats->tx_retries += MIN(retries, max_retries);
-    sw_stats->tx_failure_drops += tx_failure;
-    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
-    sw_stats->tx_qos_drops += qos_drops;
+    netdev_dpdk_vhost_update_tx_counters(dev, pkts, total_packets,
+                                         &sw_stats_add);
     rte_spinlock_unlock(&dev->stats_lock);
 
 out:
-    for (i = 0; i < total_pkts - dropped; i++) {
+    for (i = 0; i < n_packets_to_free; i++) {
         dp_packet_delete(pkts[i]);
     }
 }
Li,Rongqing via dev Nov. 11, 2019, 12:37 p.m. UTC | #4
Hi Ilya,
Thanks for the review. I agree with your proposal to move the stats update 
code to existing special functions. Thanks for the incremental patch, it looks 
good to me. Will wait for Kevin's taught on this.

Thanks & Regards,
Sriram.

-----Original Message-----
From: Ilya Maximets <i.maximets@ovn.org>
Sent: 11 November 2019 04:50
To: Sriram Vatala <sriram.v@altencalsoftlabs.com>; ovs-dev@openvswitch.org; 
ktraynor@redhat.com; i.maximets@ovn.org
Subject: Re: [PATCH v11 2/3] netdev-dpdk : Detailed packet drop statistics

On 29.10.2019 15:50, Sriram Vatala wrote:> @@ -2388,12 +2412,16 @@ 
__netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>           }
>       } while (cnt && (retries++ < max_retries));
>
> +    tx_failure = cnt;
>       rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
>
>       rte_spinlock_lock(&dev->stats_lock);
>       netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
>                                            cnt + dropped);
> -    dev->tx_retries += MIN(retries, max_retries);
> +    sw_stats->tx_retries += MIN(retries, max_retries);
> +    sw_stats->tx_failure_drops += tx_failure;
> +    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
> +    sw_stats->tx_qos_drops += qos_drops;

Kevin pointed to this part of code in hope that we can move this to a separate 
function and reuse in his review for v9.  This code catches my eyes too.  I 
don't think that we can reuse this part, at least this will be not very 
efficient in current situation (clearing of the unused fields in a stats 
structure will be probably needed before calling such a common function, but 
ETH tx uses only half of the struct).

But there is another thing here.  We already have special functions for vhost 
tx/rx counters.  And it looks strange when we're not using these functions to 
update tx/rx failure counters.

Suggesting following incremental.
Kevin, Sriram, please, share your thoughts.

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 3cb7023a8..02120a379 
100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2169,16 +2169,18 @@ netdev_dpdk_vhost_update_rx_size_counters(struct 
netdev_stats *stats,
  }

  static inline void
-netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,
+netdev_dpdk_vhost_update_rx_counters(struct netdev_dpdk *dev,
                                       struct dp_packet **packets, int count,
-                                     int dropped)
+                                     int qos_drops)
  {
-    int i;
-    unsigned int packet_size;
+    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
+    struct netdev_stats *stats = &dev->stats;
      struct dp_packet *packet;
+    unsigned int packet_size;
+    int i;

      stats->rx_packets += count;
-    stats->rx_dropped += dropped;
+    stats->rx_dropped += qos_drops;
      for (i = 0; i < count; i++) {
          packet = packets[i];
          packet_size = dp_packet_size(packet); @@ -2201,6 +2203,8 @@ 
netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,

          stats->rx_bytes += packet_size;
      }
+
+    sw_stats->rx_qos_drops += qos_drops;
  }

  /*
@@ -2213,7 +2217,7 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
      struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
      struct ingress_policer *policer = netdev_dpdk_get_ingress_policer(dev);
      uint16_t nb_rx = 0;
-    uint16_t dropped = 0;
+    uint16_t qos_drops = 0;
      int qid = rxq->queue_id * VIRTIO_QNUM + VIRTIO_TXQ;
      int vid = netdev_dpdk_get_vid(dev);

@@ -2240,17 +2244,16 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
      }

      if (policer) {
-        dropped = nb_rx;
+        qos_drops = nb_rx;
          nb_rx = ingress_policer_run(policer,
                                      (struct rte_mbuf **) batch->packets,
                                      nb_rx, true);
-        dropped -= nb_rx;
+        qos_drops -= nb_rx;
      }

      rte_spinlock_lock(&dev->stats_lock);
-    netdev_dpdk_vhost_update_rx_counters(&dev->stats, batch->packets,
-                                         nb_rx, dropped);
-    dev->sw_stats->rx_qos_drops += dropped;
+    netdev_dpdk_vhost_update_rx_counters(dev, batch->packets,
+                                         nb_rx, qos_drops);
      rte_spinlock_unlock(&dev->stats_lock);

      batch->count = nb_rx;
@@ -2360,13 +2363,18 @@ netdev_dpdk_filter_packet_len(struct netdev_dpdk *dev, 
struct rte_mbuf **pkts,
  }

  static inline void
-netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats,
+netdev_dpdk_vhost_update_tx_counters(struct netdev_dpdk *dev,
                                       struct dp_packet **packets,
                                       int attempted,
-                                     int dropped)
+                                     struct netdev_dpdk_sw_stats
+ *sw_stats_add)
  {
-    int i;
+    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
+    int dropped = sw_stats_add->tx_mtu_exceeded_drops +
+                  sw_stats_add->tx_qos_drops +
+                  sw_stats_add->tx_failure_drops;
+    struct netdev_stats *stats = &dev->stats;
      int sent = attempted - dropped;
+    int i;

      stats->tx_packets += sent;
      stats->tx_dropped += dropped;
@@ -2374,6 +2382,11 @@ netdev_dpdk_vhost_update_tx_counters(struct 
netdev_stats *stats,
      for (i = 0; i < sent; i++) {
          stats->tx_bytes += dp_packet_size(packets[i]);
      }
+
+    sw_stats->tx_retries            += sw_stats_add->tx_retries;
+    sw_stats->tx_failure_drops      += sw_stats_add->tx_failure_drops;
+    sw_stats->tx_mtu_exceeded_drops += sw_stats_add->tx_mtu_exceeded_drops;
+    sw_stats->tx_qos_drops          += sw_stats_add->tx_qos_drops;
  }

  static void
@@ -2382,12 +2395,9 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int 
qid,
  {
      struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
      struct rte_mbuf **cur_pkts = (struct rte_mbuf **) pkts;
-    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
-    unsigned int total_pkts = cnt;
-    unsigned int dropped = 0;
-    unsigned int tx_failure;
-    unsigned int mtu_drops;
-    unsigned int qos_drops;
+    struct netdev_dpdk_sw_stats sw_stats_add;
+    unsigned int n_packets_to_free = cnt;
+    unsigned int total_packets = cnt;
      int i, retries = 0;
      int max_retries = VHOST_ENQ_RETRY_MIN;
      int vid = netdev_dpdk_get_vid(dev); @@ -2408,12 +2418,14 @@ 
__netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
      }

      cnt = netdev_dpdk_filter_packet_len(dev, cur_pkts, cnt);
-    mtu_drops = total_pkts - cnt;
-    qos_drops = cnt;
+    sw_stats_add.tx_mtu_exceeded_drops = total_packets - cnt;
+
      /* Check has QoS has been configured for the netdev */
+    sw_stats_add.tx_qos_drops = cnt;
      cnt = netdev_dpdk_qos_run(dev, cur_pkts, cnt, true);
-    qos_drops -= cnt;
-    dropped = qos_drops + mtu_drops;
+    sw_stats_add.tx_qos_drops -= cnt;
+
+    n_packets_to_free = cnt;

      do {
          int vhost_qid = qid * VIRTIO_QNUM + VIRTIO_RXQ; @@ -2438,20 +2450,18 
@@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
          }
      } while (cnt && (retries++ < max_retries));

-    tx_failure = cnt;
      rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);

+    sw_stats_add.tx_failure_drops = cnt;
+    sw_stats_add.tx_retries = MIN(retries, max_retries);
+
      rte_spinlock_lock(&dev->stats_lock);
-    netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
-                                         cnt + dropped);
-    sw_stats->tx_retries += MIN(retries, max_retries);
-    sw_stats->tx_failure_drops += tx_failure;
-    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
-    sw_stats->tx_qos_drops += qos_drops;
+    netdev_dpdk_vhost_update_tx_counters(dev, pkts, total_packets,
+                                         &sw_stats_add);
      rte_spinlock_unlock(&dev->stats_lock);

  out:
-    for (i = 0; i < total_pkts - dropped; i++) {
+    for (i = 0; i < n_packets_to_free; i++) {
          dp_packet_delete(pkts[i]);
      }
  }
---

Best regards, Ilya Maximets.
Kevin Traynor Nov. 11, 2019, 3:55 p.m. UTC | #5
On 10/11/2019 23:20, Ilya Maximets wrote:
> On 29.10.2019 15:50, Sriram Vatala wrote:> @@ -2388,12 +2412,16 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>>           }
>>       } while (cnt && (retries++ < max_retries));
>>   
>> +    tx_failure = cnt;
>>       rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
>>   
>>       rte_spinlock_lock(&dev->stats_lock);
>>       netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
>>                                            cnt + dropped);
>> -    dev->tx_retries += MIN(retries, max_retries);
>> +    sw_stats->tx_retries += MIN(retries, max_retries);
>> +    sw_stats->tx_failure_drops += tx_failure;
>> +    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
>> +    sw_stats->tx_qos_drops += qos_drops;
> 
> Kevin pointed to this part of code in hope that we can move this to
> a separate function and reuse in his review for v9.  This code catches
> my eyes too.  I don't think that we can reuse this part, at least this
> will be not very efficient in current situation (clearing of the unused
> fields in a stats structure will be probably needed before calling such
> a common function, but ETH tx uses only half of the struct).
> 
> But there is another thing here.  We already have special functions
> for vhost tx/rx counters.  And it looks strange when we're not using
> these functions to update tx/rx failure counters.
> 
> Suggesting following incremental.
> Kevin, Sriram, please, share your thoughts.
> 

The incremental patch looks good, thanks. One additional thing is that
OVS_REQUIRES(dev->stats_lock) annotations can be used for the vhost
rx/tx update counter functions now (even if it seems unlikely someone
would miss doing that).

@Sriram, see below or you can check similar OVS_REQUIRES usage elsewhere
in the file.

> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index 3cb7023a8..02120a379 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -2169,16 +2169,18 @@ netdev_dpdk_vhost_update_rx_size_counters(struct netdev_stats *stats,
>   }
>   
>   static inline void
> -netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,
> +netdev_dpdk_vhost_update_rx_counters(struct netdev_dpdk *dev,
>                                        struct dp_packet **packets, int count,
> -                                     int dropped)
> +                                     int qos_drops)
    OVS_REQUIRES(dev->stats_lock)
>   {
> -    int i;
> -    unsigned int packet_size;
> +    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
> +    struct netdev_stats *stats = &dev->stats;
>       struct dp_packet *packet;
> +    unsigned int packet_size;
> +    int i;
>   
>       stats->rx_packets += count;
> -    stats->rx_dropped += dropped;
> +    stats->rx_dropped += qos_drops;
>       for (i = 0; i < count; i++) {
>           packet = packets[i];
>           packet_size = dp_packet_size(packet);
> @@ -2201,6 +2203,8 @@ netdev_dpdk_vhost_update_rx_counters(struct netdev_stats *stats,
>   
>           stats->rx_bytes += packet_size;
>       }
> +
> +    sw_stats->rx_qos_drops += qos_drops;
>   }
>   
>   /*
> @@ -2213,7 +2217,7 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
>       struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
>       struct ingress_policer *policer = netdev_dpdk_get_ingress_policer(dev);
>       uint16_t nb_rx = 0;
> -    uint16_t dropped = 0;
> +    uint16_t qos_drops = 0;
>       int qid = rxq->queue_id * VIRTIO_QNUM + VIRTIO_TXQ;
>       int vid = netdev_dpdk_get_vid(dev);
>   
> @@ -2240,17 +2244,16 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
>       }
>   
>       if (policer) {
> -        dropped = nb_rx;
> +        qos_drops = nb_rx;
>           nb_rx = ingress_policer_run(policer,
>                                       (struct rte_mbuf **) batch->packets,
>                                       nb_rx, true);
> -        dropped -= nb_rx;
> +        qos_drops -= nb_rx;
>       }
>   
>       rte_spinlock_lock(&dev->stats_lock);
> -    netdev_dpdk_vhost_update_rx_counters(&dev->stats, batch->packets,
> -                                         nb_rx, dropped);
> -    dev->sw_stats->rx_qos_drops += dropped;
> +    netdev_dpdk_vhost_update_rx_counters(dev, batch->packets,
> +                                         nb_rx, qos_drops);
>       rte_spinlock_unlock(&dev->stats_lock);
>   
>       batch->count = nb_rx;
> @@ -2360,13 +2363,18 @@ netdev_dpdk_filter_packet_len(struct netdev_dpdk *dev, struct rte_mbuf **pkts,
>   }
>   
>   static inline void
> -netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats,
> +netdev_dpdk_vhost_update_tx_counters(struct netdev_dpdk *dev,
>                                        struct dp_packet **packets,
>                                        int attempted,
> -                                     int dropped)
> +                                     struct netdev_dpdk_sw_stats *sw_stats_add)
    OVS_REQUIRES(dev->stats_lock)
>   {
> -    int i;
> +    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
> +    int dropped = sw_stats_add->tx_mtu_exceeded_drops +
> +                  sw_stats_add->tx_qos_drops +
> +                  sw_stats_add->tx_failure_drops;
> +    struct netdev_stats *stats = &dev->stats;
>       int sent = attempted - dropped;
> +    int i;
>   
>       stats->tx_packets += sent;
>       stats->tx_dropped += dropped;
> @@ -2374,6 +2382,11 @@ netdev_dpdk_vhost_update_tx_counters(struct netdev_stats *stats,
>       for (i = 0; i < sent; i++) {
>           stats->tx_bytes += dp_packet_size(packets[i]);
>       }
> +
> +    sw_stats->tx_retries            += sw_stats_add->tx_retries;
> +    sw_stats->tx_failure_drops      += sw_stats_add->tx_failure_drops;
> +    sw_stats->tx_mtu_exceeded_drops += sw_stats_add->tx_mtu_exceeded_drops;
> +    sw_stats->tx_qos_drops          += sw_stats_add->tx_qos_drops;
>   }
>   
>   static void
> @@ -2382,12 +2395,9 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>   {
>       struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
>       struct rte_mbuf **cur_pkts = (struct rte_mbuf **) pkts;
> -    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
> -    unsigned int total_pkts = cnt;
> -    unsigned int dropped = 0;
> -    unsigned int tx_failure;
> -    unsigned int mtu_drops;
> -    unsigned int qos_drops;
> +    struct netdev_dpdk_sw_stats sw_stats_add;
> +    unsigned int n_packets_to_free = cnt;
> +    unsigned int total_packets = cnt;
>       int i, retries = 0;
>       int max_retries = VHOST_ENQ_RETRY_MIN;
>       int vid = netdev_dpdk_get_vid(dev);
> @@ -2408,12 +2418,14 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>       }
>   
>       cnt = netdev_dpdk_filter_packet_len(dev, cur_pkts, cnt);
> -    mtu_drops = total_pkts - cnt;
> -    qos_drops = cnt;
> +    sw_stats_add.tx_mtu_exceeded_drops = total_packets - cnt;
> +
>       /* Check has QoS has been configured for the netdev */
> +    sw_stats_add.tx_qos_drops = cnt;
>       cnt = netdev_dpdk_qos_run(dev, cur_pkts, cnt, true);
> -    qos_drops -= cnt;
> -    dropped = qos_drops + mtu_drops;
> +    sw_stats_add.tx_qos_drops -= cnt;
> +
> +    n_packets_to_free = cnt;
>   
>       do {
>           int vhost_qid = qid * VIRTIO_QNUM + VIRTIO_RXQ;
> @@ -2438,20 +2450,18 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>           }
>       } while (cnt && (retries++ < max_retries));
>   
> -    tx_failure = cnt;
>       rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
>   
> +    sw_stats_add.tx_failure_drops = cnt;
> +    sw_stats_add.tx_retries = MIN(retries, max_retries);
> +
>       rte_spinlock_lock(&dev->stats_lock);
> -    netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
> -                                         cnt + dropped);
> -    sw_stats->tx_retries += MIN(retries, max_retries);
> -    sw_stats->tx_failure_drops += tx_failure;
> -    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
> -    sw_stats->tx_qos_drops += qos_drops;
> +    netdev_dpdk_vhost_update_tx_counters(dev, pkts, total_packets,
> +                                         &sw_stats_add);
>       rte_spinlock_unlock(&dev->stats_lock);
>   
>   out:
> -    for (i = 0; i < total_pkts - dropped; i++) {
> +    for (i = 0; i < n_packets_to_free; i++) {
>           dp_packet_delete(pkts[i]);
>       }
>   }
> ---
> 
> Best regards, Ilya Maximets.
>
Ilya Maximets Nov. 11, 2019, 3:59 p.m. UTC | #6
On 11.11.2019 16:55, Kevin Traynor wrote:
> On 10/11/2019 23:20, Ilya Maximets wrote:
>> On 29.10.2019 15:50, Sriram Vatala wrote:> @@ -2388,12 +2412,16 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>>>           }
>>>       } while (cnt && (retries++ < max_retries));
>>>   
>>> +    tx_failure = cnt;
>>>       rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
>>>   
>>>       rte_spinlock_lock(&dev->stats_lock);
>>>       netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
>>>                                            cnt + dropped);
>>> -    dev->tx_retries += MIN(retries, max_retries);
>>> +    sw_stats->tx_retries += MIN(retries, max_retries);
>>> +    sw_stats->tx_failure_drops += tx_failure;
>>> +    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
>>> +    sw_stats->tx_qos_drops += qos_drops;
>>
>> Kevin pointed to this part of code in hope that we can move this to
>> a separate function and reuse in his review for v9.  This code catches
>> my eyes too.  I don't think that we can reuse this part, at least this
>> will be not very efficient in current situation (clearing of the unused
>> fields in a stats structure will be probably needed before calling such
>> a common function, but ETH tx uses only half of the struct).
>>
>> But there is another thing here.  We already have special functions
>> for vhost tx/rx counters.  And it looks strange when we're not using
>> these functions to update tx/rx failure counters.
>>
>> Suggesting following incremental.
>> Kevin, Sriram, please, share your thoughts.
>>
> 
> The incremental patch looks good, thanks. One additional thing is that
> OVS_REQUIRES(dev->stats_lock) annotations can be used for the vhost
> rx/tx update counter functions now (even if it seems unlikely someone
> would miss doing that).
> 
> @Sriram, see below or you can check similar OVS_REQUIRES usage elsewhere
> in the file.

I'm not sure if clang annotations will work with rte_spinlock.
DPDK doesn't have proper annotations for locking functions.
Kevin Traynor Nov. 11, 2019, 4:06 p.m. UTC | #7
On 11/11/2019 15:59, Ilya Maximets wrote:
> On 11.11.2019 16:55, Kevin Traynor wrote:
>> On 10/11/2019 23:20, Ilya Maximets wrote:
>>> On 29.10.2019 15:50, Sriram Vatala wrote:> @@ -2388,12 +2412,16 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>>>>           }
>>>>       } while (cnt && (retries++ < max_retries));
>>>>   
>>>> +    tx_failure = cnt;
>>>>       rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
>>>>   
>>>>       rte_spinlock_lock(&dev->stats_lock);
>>>>       netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
>>>>                                            cnt + dropped);
>>>> -    dev->tx_retries += MIN(retries, max_retries);
>>>> +    sw_stats->tx_retries += MIN(retries, max_retries);
>>>> +    sw_stats->tx_failure_drops += tx_failure;
>>>> +    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
>>>> +    sw_stats->tx_qos_drops += qos_drops;
>>>
>>> Kevin pointed to this part of code in hope that we can move this to
>>> a separate function and reuse in his review for v9.  This code catches
>>> my eyes too.  I don't think that we can reuse this part, at least this
>>> will be not very efficient in current situation (clearing of the unused
>>> fields in a stats structure will be probably needed before calling such
>>> a common function, but ETH tx uses only half of the struct).
>>>
>>> But there is another thing here.  We already have special functions
>>> for vhost tx/rx counters.  And it looks strange when we're not using
>>> these functions to update tx/rx failure counters.
>>>
>>> Suggesting following incremental.
>>> Kevin, Sriram, please, share your thoughts.
>>>
>>
>> The incremental patch looks good, thanks. One additional thing is that
>> OVS_REQUIRES(dev->stats_lock) annotations can be used for the vhost
>> rx/tx update counter functions now (even if it seems unlikely someone
>> would miss doing that).
>>
>> @Sriram, see below or you can check similar OVS_REQUIRES usage elsewhere
>> in the file.
> 
> I'm not sure if clang annotations will work with rte_spinlock.
> DPDK doesn't have proper annotations for locking functions.
> 

Ah, good point, I didn't check the lock type. In that case nevermind,
patch+incremental LGTM as is.

Acked-by: Kevin Traynor <ktraynor@redhat.com>



thanks,
Kevin.
Ilya Maximets Nov. 11, 2019, 4:11 p.m. UTC | #8
On 11.11.2019 17:06, Kevin Traynor wrote:
> On 11/11/2019 15:59, Ilya Maximets wrote:
>> On 11.11.2019 16:55, Kevin Traynor wrote:
>>> On 10/11/2019 23:20, Ilya Maximets wrote:
>>>> On 29.10.2019 15:50, Sriram Vatala wrote:> @@ -2388,12 +2412,16 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
>>>>>           }
>>>>>       } while (cnt && (retries++ < max_retries));
>>>>>   
>>>>> +    tx_failure = cnt;
>>>>>       rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
>>>>>   
>>>>>       rte_spinlock_lock(&dev->stats_lock);
>>>>>       netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
>>>>>                                            cnt + dropped);
>>>>> -    dev->tx_retries += MIN(retries, max_retries);
>>>>> +    sw_stats->tx_retries += MIN(retries, max_retries);
>>>>> +    sw_stats->tx_failure_drops += tx_failure;
>>>>> +    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
>>>>> +    sw_stats->tx_qos_drops += qos_drops;
>>>>
>>>> Kevin pointed to this part of code in hope that we can move this to
>>>> a separate function and reuse in his review for v9.  This code catches
>>>> my eyes too.  I don't think that we can reuse this part, at least this
>>>> will be not very efficient in current situation (clearing of the unused
>>>> fields in a stats structure will be probably needed before calling such
>>>> a common function, but ETH tx uses only half of the struct).
>>>>
>>>> But there is another thing here.  We already have special functions
>>>> for vhost tx/rx counters.  And it looks strange when we're not using
>>>> these functions to update tx/rx failure counters.
>>>>
>>>> Suggesting following incremental.
>>>> Kevin, Sriram, please, share your thoughts.
>>>>
>>>
>>> The incremental patch looks good, thanks. One additional thing is that
>>> OVS_REQUIRES(dev->stats_lock) annotations can be used for the vhost
>>> rx/tx update counter functions now (even if it seems unlikely someone
>>> would miss doing that).
>>>
>>> @Sriram, see below or you can check similar OVS_REQUIRES usage elsewhere
>>> in the file.
>>
>> I'm not sure if clang annotations will work with rte_spinlock.
>> DPDK doesn't have proper annotations for locking functions.
>>
> 
> Ah, good point, I didn't check the lock type. In that case nevermind,
> patch+incremental LGTM as is.
> 
> Acked-by: Kevin Traynor <ktraynor@redhat.com>

Thanks. In this case, I think, there is no need to re-spin the series.
I'll just squash the incremental with this patch and give it another try.
If it'll work fine, I'll apply the series.

Best regards, Ilya Maximets.
Ilya Maximets Nov. 11, 2019, 6:38 p.m. UTC | #9
On 11.11.2019 17:11, Ilya Maximets wrote:
>>> I'm not sure if clang annotations will work with rte_spinlock.
>>> DPDK doesn't have proper annotations for locking functions.
>>>
>>
>> Ah, good point, I didn't check the lock type. In that case nevermind,
>> patch+incremental LGTM as is.
>>
>> Acked-by: Kevin Traynor <ktraynor@redhat.com>
> 
> Thanks. In this case, I think, there is no need to re-spin the series.
> I'll just squash the incremental with this patch and give it another try.
> If it'll work fine, I'll apply the series.

Thanks Sriram and Kevin! Series applied to master.

Best regards, Ilya Maximets.
Li,Rongqing via dev Nov. 12, 2019, 6:35 a.m. UTC | #10
Thanks Ilya and kevin.

Regards,
Sriram.

-----Original Message-----
From: Ilya Maximets <i.maximets@ovn.org>
Sent: 12 November 2019 00:08
To: Ilya Maximets <i.maximets@ovn.org>; Kevin Traynor <ktraynor@redhat.com>; 
Sriram Vatala <sriram.v@altencalsoftlabs.com>; ovs-dev@openvswitch.org
Subject: Re: [PATCH v11 2/3] netdev-dpdk : Detailed packet drop statistics

On 11.11.2019 17:11, Ilya Maximets wrote:
>>> I'm not sure if clang annotations will work with rte_spinlock.
>>> DPDK doesn't have proper annotations for locking functions.
>>>
>>
>> Ah, good point, I didn't check the lock type. In that case nevermind,
>> patch+incremental LGTM as is.
>>
>> Acked-by: Kevin Traynor <ktraynor@redhat.com>
>
> Thanks. In this case, I think, there is no need to re-spin the series.
> I'll just squash the incremental with this patch and give it another try.
> If it'll work fine, I'll apply the series.

Thanks Sriram and Kevin! Series applied to master.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/Documentation/topics/dpdk/bridge.rst b/Documentation/topics/dpdk/bridge.rst
index d9bc7eba4..f0ef42ecc 100644
--- a/Documentation/topics/dpdk/bridge.rst
+++ b/Documentation/topics/dpdk/bridge.rst
@@ -75,6 +75,12 @@  OpenFlow14`` option::
 
     $ ovs-ofctl -O OpenFlow14 dump-ports br0
 
+There are custom statistics that OVS accumulates itself and these stats has
+``ovs_`` as prefix. These custom stats are shown along with other stats
+using the following command::
+
+    $ ovs-vsctl get Interface <iface> statistics
+
 EMC Insertion Probability
 -------------------------
 
diff --git a/Documentation/topics/dpdk/vhost-user.rst b/Documentation/topics/dpdk/vhost-user.rst
index cda5b122f..ec0caeb16 100644
--- a/Documentation/topics/dpdk/vhost-user.rst
+++ b/Documentation/topics/dpdk/vhost-user.rst
@@ -551,7 +551,7 @@  processing packets at the required rate.
 The amount of Tx retries on a vhost-user or vhost-user-client interface can be
 shown with::
 
-  $ ovs-vsctl get Interface dpdkvhostclient0 statistics:tx_retries
+  $ ovs-vsctl get Interface dpdkvhostclient0 statistics:ovs_tx_retries
 
 vhost-user Dequeue Zero Copy (experimental)
 -------------------------------------------
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 2cc2516a9..6922e61ca 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -174,6 +174,20 @@  static const struct vhost_device_ops virtio_net_device_ops =
     .destroy_connection = destroy_connection,
 };
 
+/* Custom software stats for dpdk ports */
+struct netdev_dpdk_sw_stats {
+    /* No. of retries when unable to transmit. */
+    uint64_t tx_retries;
+    /* Packet drops when unable to transmit; Probably Tx queue is full. */
+    uint64_t tx_failure_drops;
+    /* Packet length greater than device MTU. */
+    uint64_t tx_mtu_exceeded_drops;
+    /* Packet drops in egress policer processing. */
+    uint64_t tx_qos_drops;
+    /* Packet drops in ingress policer processing. */
+    uint64_t rx_qos_drops;
+};
+
 enum { DPDK_RING_SIZE = 256 };
 BUILD_ASSERT_DECL(IS_POW2(DPDK_RING_SIZE));
 enum { DRAIN_TSC = 200000ULL };
@@ -416,11 +430,10 @@  struct netdev_dpdk {
 
     PADDED_MEMBERS(CACHE_LINE_SIZE,
         struct netdev_stats stats;
-        /* Custom stat for retries when unable to transmit. */
-        uint64_t tx_retries;
+        struct netdev_dpdk_sw_stats *sw_stats;
         /* Protects stats */
         rte_spinlock_t stats_lock;
-        /* 4 pad bytes here. */
+        /* 36 pad bytes here. */
     );
 
     PADDED_MEMBERS(CACHE_LINE_SIZE,
@@ -1176,7 +1189,8 @@  common_construct(struct netdev *netdev, dpdk_port_t port_no,
     dev->rte_xstats_ids = NULL;
     dev->rte_xstats_ids_size = 0;
 
-    dev->tx_retries = (dev->type == DPDK_DEV_VHOST) ? 0 : UINT64_MAX;
+    dev->sw_stats = xzalloc(sizeof *dev->sw_stats);
+    dev->sw_stats->tx_retries = (dev->type == DPDK_DEV_VHOST) ? 0 : UINT64_MAX;
 
     return 0;
 }
@@ -1362,6 +1376,7 @@  common_destruct(struct netdev_dpdk *dev)
     ovs_list_remove(&dev->list_node);
     free(ovsrcu_get_protected(struct ingress_policer *,
                               &dev->ingress_policer));
+    free(dev->sw_stats);
     ovs_mutex_destroy(&dev->mutex);
 }
 
@@ -2212,6 +2227,7 @@  netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
     rte_spinlock_lock(&dev->stats_lock);
     netdev_dpdk_vhost_update_rx_counters(&dev->stats, batch->packets,
                                          nb_rx, dropped);
+    dev->sw_stats->rx_qos_drops += dropped;
     rte_spinlock_unlock(&dev->stats_lock);
 
     batch->count = nb_rx;
@@ -2261,6 +2277,7 @@  netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct dp_packet_batch *batch,
     if (OVS_UNLIKELY(dropped)) {
         rte_spinlock_lock(&dev->stats_lock);
         dev->stats.rx_dropped += dropped;
+        dev->sw_stats->rx_qos_drops += dropped;
         rte_spinlock_unlock(&dev->stats_lock);
     }
 
@@ -2342,8 +2359,12 @@  __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
 {
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
     struct rte_mbuf **cur_pkts = (struct rte_mbuf **) pkts;
+    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
     unsigned int total_pkts = cnt;
     unsigned int dropped = 0;
+    unsigned int tx_failure;
+    unsigned int mtu_drops;
+    unsigned int qos_drops;
     int i, retries = 0;
     int max_retries = VHOST_ENQ_RETRY_MIN;
     int vid = netdev_dpdk_get_vid(dev);
@@ -2361,9 +2382,12 @@  __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
     rte_spinlock_lock(&dev->tx_q[qid].tx_lock);
 
     cnt = netdev_dpdk_filter_packet_len(dev, cur_pkts, cnt);
+    mtu_drops = total_pkts - cnt;
+    qos_drops = cnt;
     /* Check has QoS has been configured for the netdev */
     cnt = netdev_dpdk_qos_run(dev, cur_pkts, cnt, true);
-    dropped = total_pkts - cnt;
+    qos_drops -= cnt;
+    dropped = qos_drops + mtu_drops;
 
     do {
         int vhost_qid = qid * VIRTIO_QNUM + VIRTIO_RXQ;
@@ -2388,12 +2412,16 @@  __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
         }
     } while (cnt && (retries++ < max_retries));
 
+    tx_failure = cnt;
     rte_spinlock_unlock(&dev->tx_q[qid].tx_lock);
 
     rte_spinlock_lock(&dev->stats_lock);
     netdev_dpdk_vhost_update_tx_counters(&dev->stats, pkts, total_pkts,
                                          cnt + dropped);
-    dev->tx_retries += MIN(retries, max_retries);
+    sw_stats->tx_retries += MIN(retries, max_retries);
+    sw_stats->tx_failure_drops += tx_failure;
+    sw_stats->tx_mtu_exceeded_drops += mtu_drops;
+    sw_stats->tx_qos_drops += qos_drops;
     rte_spinlock_unlock(&dev->stats_lock);
 
 out:
@@ -2416,14 +2444,18 @@  dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch)
 #endif
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
     struct rte_mbuf *pkts[PKT_ARRAY_SIZE];
+    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
     uint32_t cnt = batch_cnt;
     uint32_t dropped = 0;
+    uint32_t tx_failure = 0;
+    uint32_t mtu_drops = 0;
+    uint32_t qos_drops = 0;
 
     if (dev->type != DPDK_DEV_VHOST) {
         /* Check if QoS has been configured for this netdev. */
         cnt = netdev_dpdk_qos_run(dev, (struct rte_mbuf **) batch->packets,
                                   batch_cnt, false);
-        dropped += batch_cnt - cnt;
+        qos_drops = batch_cnt - cnt;
     }
 
     uint32_t txcnt = 0;
@@ -2436,13 +2468,13 @@  dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch)
             VLOG_WARN_RL(&rl, "Too big size %u max_packet_len %d",
                          size, dev->max_packet_len);
 
-            dropped++;
+            mtu_drops++;
             continue;
         }
 
         pkts[txcnt] = rte_pktmbuf_alloc(dev->dpdk_mp->mp);
         if (OVS_UNLIKELY(!pkts[txcnt])) {
-            dropped += cnt - i;
+            dropped = cnt - i;
             break;
         }
 
@@ -2459,13 +2491,17 @@  dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet_batch *batch)
             __netdev_dpdk_vhost_send(netdev, qid, (struct dp_packet **) pkts,
                                      txcnt);
         } else {
-            dropped += netdev_dpdk_eth_tx_burst(dev, qid, pkts, txcnt);
+            tx_failure = netdev_dpdk_eth_tx_burst(dev, qid, pkts, txcnt);
         }
     }
 
+    dropped += qos_drops + mtu_drops + tx_failure;
     if (OVS_UNLIKELY(dropped)) {
         rte_spinlock_lock(&dev->stats_lock);
         dev->stats.tx_dropped += dropped;
+        sw_stats->tx_failure_drops += tx_failure;
+        sw_stats->tx_mtu_exceeded_drops += mtu_drops;
+        sw_stats->tx_qos_drops += qos_drops;
         rte_spinlock_unlock(&dev->stats_lock);
     }
 }
@@ -2507,19 +2543,27 @@  netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
         dpdk_do_tx_copy(netdev, qid, batch);
         dp_packet_delete_batch(batch, true);
     } else {
+        struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
         int tx_cnt, dropped;
+        int tx_failure, mtu_drops, qos_drops;
         int batch_cnt = dp_packet_batch_size(batch);
         struct rte_mbuf **pkts = (struct rte_mbuf **) batch->packets;
 
         tx_cnt = netdev_dpdk_filter_packet_len(dev, pkts, batch_cnt);
+        mtu_drops = batch_cnt - tx_cnt;
+        qos_drops = tx_cnt;
         tx_cnt = netdev_dpdk_qos_run(dev, pkts, tx_cnt, true);
-        dropped = batch_cnt - tx_cnt;
+        qos_drops -= tx_cnt;
 
-        dropped += netdev_dpdk_eth_tx_burst(dev, qid, pkts, tx_cnt);
+        tx_failure = netdev_dpdk_eth_tx_burst(dev, qid, pkts, tx_cnt);
 
+        dropped = tx_failure + mtu_drops + qos_drops;
         if (OVS_UNLIKELY(dropped)) {
             rte_spinlock_lock(&dev->stats_lock);
             dev->stats.tx_dropped += dropped;
+            sw_stats->tx_failure_drops += tx_failure;
+            sw_stats->tx_mtu_exceeded_drops += mtu_drops;
+            sw_stats->tx_qos_drops += qos_drops;
             rte_spinlock_unlock(&dev->stats_lock);
         }
     }
@@ -2830,8 +2874,12 @@  netdev_dpdk_get_sw_custom_stats(const struct netdev *netdev,
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
     int i, n;
 
-#define SW_CSTATS \
-    SW_CSTAT(tx_retries)
+#define SW_CSTATS                    \
+    SW_CSTAT(tx_retries)             \
+    SW_CSTAT(tx_failure_drops)       \
+    SW_CSTAT(tx_mtu_exceeded_drops)  \
+    SW_CSTAT(tx_qos_drops)           \
+    SW_CSTAT(rx_qos_drops)
 
 #define SW_CSTAT(NAME) + 1
     custom_stats->size = SW_CSTATS;
@@ -2844,7 +2892,7 @@  netdev_dpdk_get_sw_custom_stats(const struct netdev *netdev,
     rte_spinlock_lock(&dev->stats_lock);
     i = 0;
 #define SW_CSTAT(NAME) \
-    custom_stats->counters[i++].value = dev->NAME;
+    custom_stats->counters[i++].value = dev->sw_stats->NAME;
     SW_CSTATS;
 #undef SW_CSTAT
     rte_spinlock_unlock(&dev->stats_lock);
@@ -2855,8 +2903,8 @@  netdev_dpdk_get_sw_custom_stats(const struct netdev *netdev,
     n = 0;
 #define SW_CSTAT(NAME) \
     if (custom_stats->counters[i].value != UINT64_MAX) {                   \
-        ovs_strlcpy(custom_stats->counters[n].name, #NAME,                 \
-                    NETDEV_CUSTOM_STATS_NAME_SIZE);                        \
+        ovs_strlcpy(custom_stats->counters[n].name,                        \
+                    "ovs_"#NAME, NETDEV_CUSTOM_STATS_NAME_SIZE);           \
         custom_stats->counters[n].value = custom_stats->counters[i].value; \
         n++;                                                               \
     }                                                                      \