mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
netdev: Add netdev_get_speed() to netdev API.
Currently, the netdev's speed is being calculated by taking the link's feature bits (using netdev_get_features()) and transforming them into bps. This mechanism can be both inaccurate and difficult to maintain, mainly because we currently use the feature bits supported by OpenFlow which would have to be extended to support all new feature bits of all netdev implementations while keeping the OpenFlow API intact. In order to expose the link speed accurately for all current and future hardware, add a new netdev API call that allows the implementations to provide the current and maximum link speeds in Mbps. Internally, the logic to get the maximum supported speed still relies on feature bits so it might still get out of sync in the future. However, the maximum configurable speed is not used as much as the current speed and these feature bits are not exposed through the netdev interface so it should be easier to add more. Use this new function instead of netdev_get_features() where the link speed is needed. As a consequence of this patch, link speeds of cards is properly reported (internally in OVSDB) even if not supported by OpenFlow. A test verifies this behavior using a tap device. Also, in order to avoid using the old, this patch adds a checkpatch.py warning if the old API is used. Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2137567 Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
committed by
Ilya Maximets
parent
1ef3f4f78a
commit
6240c0b4c8
@@ -1168,6 +1168,27 @@ cleanup:
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
netdev_bsd_get_speed(const struct netdev *netdev, uint32_t *current,
|
||||
uint32_t *max)
|
||||
{
|
||||
enum netdev_features f_current, f_supported, f_advertised, f_peer;
|
||||
int error;
|
||||
|
||||
error = netdev_bsd_get_features(netdev, &f_current, &f_advertised,
|
||||
&f_supported, &f_peer);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
*current = MIN(UINT32_MAX,
|
||||
netdev_features_to_bps(f_current, 0) / 1000000ULL);
|
||||
*max = MIN(UINT32_MAX,
|
||||
netdev_features_to_bps(f_supported, 0) / 1000000ULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Assigns 'addr' as 'netdev''s IPv4 address and 'mask' as its netmask. If
|
||||
* 'addr' is INADDR_ANY, 'netdev''s IPv4 address is cleared. Returns a
|
||||
@@ -1493,6 +1514,7 @@ netdev_bsd_update_flags(struct netdev *netdev_, enum netdev_flags off,
|
||||
.get_carrier = netdev_bsd_get_carrier, \
|
||||
.get_stats = netdev_bsd_get_stats, \
|
||||
.get_features = netdev_bsd_get_features, \
|
||||
.get_speed = netdev_bsd_get_speed, \
|
||||
.set_in4 = netdev_bsd_set_in4, \
|
||||
.get_addr_list = netdev_bsd_get_addr_list, \
|
||||
.get_next_hop = netdev_bsd_get_next_hop, \
|
||||
|
Reference in New Issue
Block a user