From: Ben Pfaff Date: Mon, 2 Mar 2009 18:48:00 +0000 (-0800) Subject: netdev: New function netdev_set_advertisements(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0eaf10c2a0fd354bfa3c9fbcf13c9f41bfcc05d3;p=openvswitch netdev: New function netdev_set_advertisements(). The new implementation of the switch needs to do this from userspace. --- diff --git a/lib/netdev.c b/lib/netdev.c index 3921c4a0..d46ab2d9 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -730,6 +730,58 @@ netdev_get_features(struct netdev *netdev, peer ? peer : &dummy[3]); } +int +netdev_set_advertisements(struct netdev *netdev, uint32_t advertise) +{ + struct ethtool_cmd ecmd; + int error; + + memset(&ecmd, 0, sizeof ecmd); + error = do_ethtool(netdev, &ecmd, ETHTOOL_GSET, "ETHTOOL_GSET"); + if (error) { + return error; + } + + ecmd.advertising = 0; + if (advertise & OFPPF_10MB_HD) { + ecmd.advertising |= ADVERTISED_10baseT_Half; + } + if (advertise & OFPPF_10MB_FD) { + ecmd.advertising |= ADVERTISED_10baseT_Full; + } + if (advertise & OFPPF_100MB_HD) { + ecmd.advertising |= ADVERTISED_100baseT_Half; + } + if (advertise & OFPPF_100MB_FD) { + ecmd.advertising |= ADVERTISED_100baseT_Full; + } + if (advertise & OFPPF_1GB_HD) { + ecmd.advertising |= ADVERTISED_1000baseT_Half; + } + if (advertise & OFPPF_1GB_FD) { + ecmd.advertising |= ADVERTISED_1000baseT_Full; + } + if (advertise & OFPPF_10GB_FD) { + ecmd.advertising |= ADVERTISED_10000baseT_Full; + } + if (advertise & OFPPF_COPPER) { + ecmd.advertising |= ADVERTISED_TP; + } + if (advertise & OFPPF_FIBER) { + ecmd.advertising |= ADVERTISED_FIBRE; + } + if (advertise & OFPPF_AUTONEG) { + ecmd.advertising |= ADVERTISED_Autoneg; + } + if (advertise & OFPPF_PAUSE) { + ecmd.advertising |= ADVERTISED_Pause; + } + if (advertise & OFPPF_PAUSE_ASYM) { + ecmd.advertising |= ADVERTISED_Asym_Pause; + } + return do_ethtool(netdev, &ecmd, ETHTOOL_SSET, "ETHTOOL_SSET"); +} + /* If 'netdev' has an assigned IPv4 address, sets '*in4' to that address (if * 'in4' is non-null) and returns true. Otherwise, returns false. */ bool diff --git a/lib/netdev.h b/lib/netdev.h index d60fe356..dd6174e2 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -107,6 +107,7 @@ int netdev_get_mtu(const struct netdev *); int netdev_get_features(struct netdev *, uint32_t *current, uint32_t *advertised, uint32_t *supported, uint32_t *peer); +int netdev_set_advertisements(struct netdev *, uint32_t advertise); bool netdev_get_in4(const struct netdev *, struct in_addr *); int netdev_set_in4(struct netdev *, struct in_addr addr, struct in_addr mask); int netdev_add_router(struct in_addr router);