+\f
+/* Code specific to patch ports. */
+
+/* If 'netdev' is a patch port, returns the name of its peer as a malloc()'d
+ * string that the caller must free.
+ *
+ * If 'netdev' is not a patch port, returns NULL. */
+char *
+netdev_vport_patch_peer(const struct netdev *netdev_)
+{
+ char *peer = NULL;
+
+ if (netdev_vport_is_patch(netdev_)) {
+ struct netdev_vport *netdev = netdev_vport_cast(netdev_);
+
+ ovs_mutex_lock(&netdev->mutex);
+ if (netdev->peer) {
+ peer = xstrdup(netdev->peer);
+ }
+ ovs_mutex_unlock(&netdev->mutex);
+ }
+
+ return peer;
+}
+
+void
+netdev_vport_inc_rx(const struct netdev *netdev,
+ const struct dpif_flow_stats *stats)
+{
+ if (is_vport_class(netdev_get_class(netdev))) {
+ struct netdev_vport *dev = netdev_vport_cast(netdev);
+
+ ovs_mutex_lock(&dev->mutex);
+ dev->stats.rx_packets += stats->n_packets;
+ dev->stats.rx_bytes += stats->n_bytes;
+ ovs_mutex_unlock(&dev->mutex);
+ }
+}
+
+void
+netdev_vport_inc_tx(const struct netdev *netdev,
+ const struct dpif_flow_stats *stats)
+{
+ if (is_vport_class(netdev_get_class(netdev))) {
+ struct netdev_vport *dev = netdev_vport_cast(netdev);
+
+ ovs_mutex_lock(&dev->mutex);
+ dev->stats.tx_packets += stats->n_packets;
+ dev->stats.tx_bytes += stats->n_bytes;
+ ovs_mutex_unlock(&dev->mutex);
+ }
+}
+
+static int
+get_patch_config(const struct netdev *dev_, struct smap *args)
+{
+ struct netdev_vport *dev = netdev_vport_cast(dev_);
+
+ ovs_mutex_lock(&dev->mutex);
+ if (dev->peer) {
+ smap_add(args, "peer", dev->peer);
+ }
+ ovs_mutex_unlock(&dev->mutex);
+
+ return 0;
+}