def _get_pcinet_info(self, vf_address): """Returns a dict of NET device.""" devname = pci_utils.get_net_name_by_vf_pci_address(vf_address) if not devname: return ifname = pci_utils.get_ifname_by_pci_address(vf_address) # Features from the that libvirt supported, get them by ethtool -k # Note: I cannot find the rdma feature returned by ethtool, correct me # if the string is wrong. FEATURES_LIST = [ 'rx-checksumming', 'tx-checksumming', 'scatter-gather', 'tcp-segmentation-offload', 'generic-segmentation-offload', 'generic-receive-offload', 'large-receive-offload', 'rx-vlan-offload', 'tx-vlan-offload', 'ntuple-filters', 'receive-hashing', 'tx-udp_tnl-segmentation', 'rdma' ] FEATURES_MAP = { 'rx-checksumming': 'rx', 'tx-checksumming': 'tx', 'scatter-gather': 'sg', 'tcp-segmentation-offload': 'tso', 'generic-segmentation-offload': 'gso', 'generic-receive-offload': 'gro', 'large-receive-offload': 'lro', 'rx-vlan-offload': 'rxvlan', 'tx-vlan-offload': 'txvlan', 'ntuple-filters': 'ntuple', 'receive-hashing': 'rxhash', 'tx-udp_tnl-segmentation': 'txudptnl', 'rdma': 'rdma' } features = [] try: output, status = processutils.execute('ethtool', '-k', ifname) lines = output.split('\n') for line in lines: columns = line.split(":") if columns[0].strip() in FEATURES_LIST: if "on" in columns[1].strip(): features.append(FEATURES_MAP.get(columns[0].strip())) except processutils.ProcessExecutionError: raise exception.CommandError(cmd='ethtool -k') return {'name': devname, 'capabilities': features}
def _get_pcinet_info(self, vf_address): """Returns a dict of NET device.""" devname = pci_utils.get_net_name_by_vf_pci_address(vf_address) if not devname: return ifname = pci_utils.get_ifname_by_pci_address(vf_address) # Features from the that libvirt supported, get them by ethtool -k # Note: I cannot find the rdma feature returned by ethtool, correct me # if the string is wrong. FEATURES_LIST = ['rx-checksumming', 'tx-checksumming', 'scatter-gather', 'tcp-segmentation-offload', 'generic-segmentation-offload', 'generic-receive-offload', 'large-receive-offload', 'rx-vlan-offload', 'tx-vlan-offload', 'ntuple-filters', 'receive-hashing', 'tx-udp_tnl-segmentation', 'rdma'] FEATURES_MAP = {'rx-checksumming': 'rx', 'tx-checksumming': 'tx', 'scatter-gather': 'sg', 'tcp-segmentation-offload': 'tso', 'generic-segmentation-offload': 'gso', 'generic-receive-offload': 'gro', 'large-receive-offload': 'lro', 'rx-vlan-offload': 'rxvlan', 'tx-vlan-offload': 'txvlan', 'ntuple-filters': 'ntuple', 'receive-hashing': 'rxhash', 'tx-udp_tnl-segmentation': 'txudptnl', 'rdma': 'rdma'} features = [] output, status = utils.execute('ethtool', '-k', ifname) lines = output.split('\n') for line in lines: columns = line.split(":") if columns[0].strip() in FEATURES_LIST: if "on" in columns[1].strip(): features.append(FEATURES_MAP.get(columns[0].strip())) return {'name': devname, 'capabilities': features}
def test_virtual_function_inferface_name(self, mock_listdir): mock_listdir.return_value = ['foo', 'bar'] ifname = utils.get_ifname_by_pci_address( self.pci_address, pf_interface=False) self.assertEqual(ifname, 'bar')