ofproto: Drop unneeded poll_immediate_wake().
[openvswitch] / lib / netdev-vport.c
index a81262a6cae5caa92d028b45ce73709bf964298f..35092d25caa0e522dc3b97b693d91cff56681129 100644 (file)
@@ -7,7 +7,7 @@
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or apatched to in writing, software
+ * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
 #include "openvswitch/datapath-protocol.h"
 #include "shash.h"
 #include "socket-util.h"
-
-#define THIS_MODULE VLM_netdev_vport
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(netdev_vport)
+
 struct netdev_vport_notifier {
     struct netdev_notifier notifier;
     struct list list_node;
-    struct shash_node *shash_node; 
+    struct shash_node *shash_node;
 };
 
 static struct shash netdev_vport_notifiers =
@@ -158,6 +158,40 @@ netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats)
     return 0;
 }
 
+int
+netdev_vport_set_stats(struct netdev *netdev, const struct netdev_stats *stats)
+{
+    struct odp_vport_stats_req ovsr;
+    int err;
+
+    ovs_strlcpy(ovsr.devname, netdev_get_name(netdev), sizeof ovsr.devname);
+
+    ovsr.stats.rx_packets = stats->rx_packets;
+    ovsr.stats.tx_packets = stats->tx_packets;
+    ovsr.stats.rx_bytes = stats->rx_bytes;
+    ovsr.stats.tx_bytes = stats->tx_bytes;
+    ovsr.stats.rx_errors = stats->rx_errors;
+    ovsr.stats.tx_errors = stats->tx_errors;
+    ovsr.stats.rx_dropped = stats->rx_dropped;
+    ovsr.stats.tx_dropped = stats->tx_dropped;
+    ovsr.stats.collisions = stats->collisions;
+    ovsr.stats.rx_over_err = stats->rx_over_errors;
+    ovsr.stats.rx_crc_err = stats->rx_crc_errors;
+    ovsr.stats.rx_frame_err = stats->rx_frame_errors;
+
+    err = netdev_vport_do_ioctl(ODP_VPORT_STATS_SET, &ovsr);
+
+    /* If the vport layer doesn't know about the device, that doesn't mean it
+     * doesn't exist (after all were able to open it when netdev_open() was
+     * called), it just means that it isn't attached and we'll be getting
+     * stats a different way. */
+    if (err == ENODEV) {
+        err = EOPNOTSUPP;
+    }
+
+    return err;
+}
+
 int
 netdev_vport_update_flags(struct netdev *netdev OVS_UNUSED,
                         enum netdev_flags off, enum netdev_flags on OVS_UNUSED,
@@ -235,8 +269,7 @@ netdev_vport_poll_notify(const struct netdev *netdev)
     if (list) {
         struct netdev_vport_notifier *notifier;
 
-        LIST_FOR_EACH (notifier, struct netdev_vport_notifier,
-                       list_node, list) {
+        LIST_FOR_EACH (notifier, list_node, list) {
             struct netdev_notifier *n = &notifier->notifier;
             n->cb(n);
         }