netdev-linux: Reorganize slightly.
authorBen Pfaff <blp@nicira.com>
Thu, 10 Nov 2011 00:52:16 +0000 (16:52 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 23 Nov 2011 21:19:53 +0000 (13:19 -0800)
lib/netdev-linux.c

index dddec33..134d99b 100644 (file)
@@ -3930,6 +3930,55 @@ tc_calc_buffer(unsigned int Bps, int mtu, uint64_t burst_bytes)
     return tc_bytes_to_ticks(Bps, MAX(burst_bytes, min_burst));
 }
 \f
+/* Linux-only functions declared in netdev-linux.h  */
+
+/* Modifies the 'flag' bit in ethtool's flags field for 'netdev'.  If
+ * 'enable' is true, the bit is set.  Otherwise, it is cleared. */
+int
+netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag,
+                              const char *flag_name, bool enable)
+{
+    const char *netdev_name = netdev_get_name(netdev);
+    struct ethtool_value evalue;
+    uint32_t new_flags;
+    int error;
+
+    memset(&evalue, 0, sizeof evalue);
+    error = netdev_linux_do_ethtool(netdev_name,
+                                    (struct ethtool_cmd *)&evalue,
+                                    ETHTOOL_GFLAGS, "ETHTOOL_GFLAGS");
+    if (error) {
+        return error;
+    }
+
+    evalue.data = new_flags = (evalue.data & ~flag) | (enable ? flag : 0);
+    error = netdev_linux_do_ethtool(netdev_name,
+                                    (struct ethtool_cmd *)&evalue,
+                                    ETHTOOL_SFLAGS, "ETHTOOL_SFLAGS");
+    if (error) {
+        return error;
+    }
+
+    memset(&evalue, 0, sizeof evalue);
+    error = netdev_linux_do_ethtool(netdev_name,
+                                    (struct ethtool_cmd *)&evalue,
+                                    ETHTOOL_GFLAGS, "ETHTOOL_GFLAGS");
+    if (error) {
+        return error;
+    }
+
+    if (new_flags != evalue.data) {
+        VLOG_WARN_RL(&rl, "attempt to %s ethtool %s flag on network "
+                     "device %s failed", enable ? "enable" : "disable",
+                     flag_name, netdev_name);
+        return EOPNOTSUPP;
+    }
+
+    return 0;
+}
+\f
+/* Utility functions. */
+
 /* Copies 'src' into 'dst', performing format conversion in the process. */
 static void
 netdev_stats_from_rtnl_link_stats(struct netdev_stats *dst,
@@ -3958,9 +4007,6 @@ netdev_stats_from_rtnl_link_stats(struct netdev_stats *dst,
     dst->tx_window_errors = src->tx_window_errors;
 }
 
-\f
-/* Utility functions. */
-
 static int
 get_stats_via_netlink(int ifindex, struct netdev_stats *stats)
 {
@@ -4247,51 +4293,6 @@ netdev_linux_do_ethtool(const char *name, struct ethtool_cmd *ecmd,
     }
 }
 
-/* Modifies the 'flag' bit in ethtool's flags field for 'netdev'.  If
- * 'enable' is true, the bit is set.  Otherwise, it is cleared. */
-int
-netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag,
-                              const char *flag_name, bool enable)
-{
-    const char *netdev_name = netdev_get_name(netdev);
-    struct ethtool_value evalue;
-    uint32_t new_flags;
-    int error;
-
-    memset(&evalue, 0, sizeof evalue);
-    error = netdev_linux_do_ethtool(netdev_name,
-                                    (struct ethtool_cmd *)&evalue,
-                                    ETHTOOL_GFLAGS, "ETHTOOL_GFLAGS");
-    if (error) {
-        return error;
-    }
-
-    evalue.data = new_flags = (evalue.data & ~flag) | (enable ? flag : 0);
-    error = netdev_linux_do_ethtool(netdev_name,
-                                    (struct ethtool_cmd *)&evalue,
-                                    ETHTOOL_SFLAGS, "ETHTOOL_SFLAGS");
-    if (error) {
-        return error;
-    }
-
-    memset(&evalue, 0, sizeof evalue);
-    error = netdev_linux_do_ethtool(netdev_name,
-                                    (struct ethtool_cmd *)&evalue,
-                                    ETHTOOL_GFLAGS, "ETHTOOL_GFLAGS");
-    if (error) {
-        return error;
-    }
-
-    if (new_flags != evalue.data) {
-        VLOG_WARN_RL(&rl, "attempt to %s ethtool %s flag on network "
-                     "device %s failed", enable ? "enable" : "disable",
-                     flag_name, netdev_name);
-        return EOPNOTSUPP;
-    }
-
-    return 0;
-}
-
 static int
 netdev_linux_do_ioctl(const char *name, struct ifreq *ifr, int cmd,
                       const char *cmd_name)