Looks good. I'm assuming the code of netdev_linux_ethool_set_flag() didn't change I didn't read it.
Ethan On Tue, Nov 15, 2011 at 17:17, Ben Pfaff <b...@nicira.com> wrote: > --- > lib/netdev-linux.c | 97 ++++++++++++++++++++++++++------------------------- > 1 files changed, 49 insertions(+), 48 deletions(-) > > diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c > index dddec33..134d99b 100644 > --- a/lib/netdev-linux.c > +++ b/lib/netdev-linux.c > @@ -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)); > } > > +/* 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; > +} > + > +/* 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; > } > > - > -/* 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) > -- > 1.7.4.4 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev