[dts] [PATCH for-next v2 2/3] nics/net_device: add a function to get nic speed

Liu, Yong yong.liu at intel.com
Fri Mar 30 10:29:01 CEST 2018


Hi Ali,
Since kernel module is the precondition of NIC interface, please add 
wrapper function nic_has_driver.

Thanks,
Marvin

On 03/30/2018 07:47 AM, Ali Alnubani wrote:
> Needed to differentiate between nics with same
> device identifier, but with different speeds.
>
> Signed-off-by: Ali Alnubani <alialnu at mellanox.com>
> ---
>   nics/net_device.py | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
>
> diff --git a/nics/net_device.py b/nics/net_device.py
> index 4861145..0f4bac3 100644
> --- a/nics/net_device.py
> +++ b/nics/net_device.py
> @@ -539,6 +539,20 @@ class NetDevice(object):
>           """
>           return self.crb.get_pci_dev_id(self.domain_id, self.bus_id, self.devfun_id)
>   
> +    def get_nic_speed(self):
> +        """
> +        Get the speed of specified pci device.
> +        """
> +        nic_speed = None
> +        command = ('cat /sys/bus/pci/devices/%s\:%s\:%s/net/*/speed' % ( \
> +                self.domain_id, self.bus_id, self.devfun_id))
> +        try:
> +            nic_speed = self.__send_expect(command, '# ')
> +        except Exception as e:
> +            print 'Failed to get the speed of the pci device [%s:%s:%s]: %s' \
> +                    % (self.domain_id, self.bus_id, self.devfun_id, e)
> +        return nic_speed
> +
>       @nic_has_driver
>       def get_sriov_vfs_pci(self):
>           """



More information about the dts mailing list