enum netdev_features current;
netdev_get_features(netdev, ¤t, NULL, NULL, NULL);
- hc->max_rate = netdev_features_to_bps(current) / 8;
+ hc->max_rate = netdev_features_to_bps(current, 100 * 1000 * 1000) / 8;
}
hc->min_rate = hc->max_rate;
hc->burst = 0;
enum netdev_features current;
netdev_get_features(netdev, ¤t, NULL, NULL, NULL);
- max_rate = netdev_features_to_bps(current) / 8;
+ max_rate = netdev_features_to_bps(current, 100 * 1000 * 1000) / 8;
}
class->min_rate = max_rate;
/* Returns the maximum speed of a network connection that has the NETDEV_F_*
* bits in 'features', in bits per second. If no bits that indicate a speed
- * are set in 'features', assumes 100Mbps. */
+ * are set in 'features', returns 'default_bps'. */
uint64_t
-netdev_features_to_bps(enum netdev_features features)
+netdev_features_to_bps(enum netdev_features features,
+ uint64_t default_bps)
{
enum {
F_1000000MB = NETDEV_F_1TB_FD,
: features & F_1000MB ? UINT64_C(1000000000)
: features & F_100MB ? UINT64_C(100000000)
: features & F_10MB ? UINT64_C(10000000)
- : UINT64_C(100000000));
+ : default_bps);
}
/* Returns true if any of the NETDEV_F_* bits that indicate a full-duplex link
enum netdev_features *advertised,
enum netdev_features *supported,
enum netdev_features *peer);
-uint64_t netdev_features_to_bps(enum netdev_features features);
+uint64_t netdev_features_to_bps(enum netdev_features features,
+ uint64_t default_bps);
bool netdev_features_is_full_duplex(enum netdev_features features);
int netdev_set_advertisements(struct netdev *, enum netdev_features advertise);
pp->supported = netdev_port_features_from_ofp10(opp->supported);
pp->peer = netdev_port_features_from_ofp10(opp->peer);
- pp->curr_speed = netdev_features_to_bps(pp->curr) / 1000;
- pp->max_speed = netdev_features_to_bps(pp->supported) / 1000;
+ pp->curr_speed = netdev_features_to_bps(pp->curr, 0) / 1000;
+ pp->max_speed = netdev_features_to_bps(pp->supported, 0) / 1000;
return 0;
}
if (!netdev_get_features(dsp->ofport->netdev, ¤t, NULL, NULL, NULL)) {
/* The values of ifDirection come from MAU MIB (RFC 2668): 0 = unknown,
1 = full-duplex, 2 = half-duplex, 3 = in, 4=out */
- counters->ifSpeed = netdev_features_to_bps(current);
+ counters->ifSpeed = netdev_features_to_bps(current, 0);
counters->ifDirection = (netdev_features_is_full_duplex(current)
? 1 : 2);
} else {
pp->state = netdev_get_carrier(netdev) ? 0 : OFPUTIL_PS_LINK_DOWN;
netdev_get_features(netdev, &pp->curr, &pp->advertised,
&pp->supported, &pp->peer);
- pp->curr_speed = netdev_features_to_bps(pp->curr);
- pp->max_speed = netdev_features_to_bps(pp->supported);
+ pp->curr_speed = netdev_features_to_bps(pp->curr, 0);
+ pp->max_speed = netdev_features_to_bps(pp->supported, 0);
return netdev;
}
LOCAL(br0): addr:50:54:00:00:00:01
config: PORT_DOWN
state: LINK_DOWN
- speed: 100 Mbps now, 100 Mbps max
+ speed: 0 Mbps now, 0 Mbps max
])
AT_CLEANUP
LOCAL(br0): addr:aa:55:aa:55:00:00
config: PORT_DOWN
state: LINK_DOWN
- speed: 100 Mbps now, 100 Mbps max
+ speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
])
OVS_VSWITCHD_STOP
1(p1): addr:aa:55:aa:55:00:0x
config: PORT_DOWN
state: LINK_DOWN
- speed: 100 Mbps now, 100 Mbps max
+ speed: 0 Mbps now, 0 Mbps max
99(p2): addr:aa:55:aa:55:00:0x
config: PORT_DOWN
state: LINK_DOWN
- speed: 100 Mbps now, 100 Mbps max
+ speed: 0 Mbps now, 0 Mbps max
LOCAL(br0): addr:aa:55:aa:55:00:0x
config: PORT_DOWN
state: LINK_DOWN
- speed: 100 Mbps now, 100 Mbps max
+ speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
])
LOCAL(br0): addr:aa:55:aa:55:00:00
config: PORT_DOWN
state: LINK_DOWN
- speed: 100 Mbps now, 100 Mbps max
+ speed: 0 Mbps now, 0 Mbps max
])
OVS_VSWITCHD_STOP
AT_CLEANUP
LOCAL(br0): addr:aa:55:aa:55:00:00
config: $config
state: $state
- speed: 100 Mbps now, 100 Mbps max
+ speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
])
done
echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
config: PORT_DOWN
state: LINK_DOWN
- speed: 100 Mbps now, 100 Mbps max"
+ speed: 0 Mbps now, 0 Mbps max"
fi
# OFPT_PORT_STATUS, OFPPR_DELETE
echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
config: PORT_DOWN
state: LINK_DOWN
- speed: 100 Mbps now, 100 Mbps max"
+ speed: 0 Mbps now, 0 Mbps max"
fi
# OFPT_FLOW_REMOVED, OFPRR_DELETE
port_s->path_cost = strtoul(config_str, NULL, 10);
} else {
enum netdev_features current;
+ unsigned int mbps;
- if (netdev_get_features(iface->netdev, ¤t, NULL, NULL, NULL)) {
- /* Couldn't get speed, so assume 100Mb/s. */
- port_s->path_cost = 19;
- } else {
- unsigned int mbps;
-
- mbps = netdev_features_to_bps(current) / 1000000;
- port_s->path_cost = stp_convert_speed_to_cost(mbps);
- }
+ netdev_get_features(iface->netdev, ¤t, NULL, NULL, NULL);
+ mbps = netdev_features_to_bps(current, 100 * 1000 * 1000) / 1000000;
+ port_s->path_cost = stp_convert_speed_to_cost(mbps);
}
config_str = smap_get(&port->cfg->other_config, "stp-port-priority");
smap_destroy(&smap);
error = netdev_get_features(iface->netdev, ¤t, NULL, NULL, NULL);
- if (!error) {
+ bps = !error ? netdev_features_to_bps(current, 0) : 0;
+ if (bps) {
ovsrec_interface_set_duplex(iface->cfg,
netdev_features_is_full_duplex(current)
? "full" : "half");
- /* warning: uint64_t -> int64_t conversion */
- bps = netdev_features_to_bps(current);
ovsrec_interface_set_link_speed(iface->cfg, &bps, 1);
}
else {