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,
dst->tx_window_errors = src->tx_window_errors;
}
-\f
-/* Utility functions. */
-
static int
get_stats_via_netlink(int ifindex, struct netdev_stats *stats)
{
}
}
-/* 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)