debuggers.hg

changeset 20010:091036b8dbb9

xend: pass-through: use identity-mapping of PCI functions

This reverses changeset "xend: pass-through: Implement least-mapping
of virtual" (19854:22067ba1de0d) and reverts the code to identity
mapping physical PCI functions to virtual ones when multi-function
virtual devices are in use. It is my opinion that this is both safer
and simpler than least-mapping, and that in the absence of further
analysis identity-mapping the best choice for now.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jul 22 14:05:26 2009 +0100 (2009-07-22)
parents 4fc621f62ed1
children 5adc108c0085
files tools/python/xen/util/pci.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/util/pci.py	Wed Jul 22 14:04:14 2009 +0100
     1.2 +++ b/tools/python/xen/util/pci.py	Wed Jul 22 14:05:26 2009 +0100
     1.3 @@ -287,13 +287,19 @@ def parse_pci_name_extended(pci_dev_str)
     1.4      # Virtual slot assignment takes place here if specified in the bdf,
     1.5      # else it is done inside qemu-xen, as it knows which slots are free
     1.6      pci = []
     1.7 -    vfunc = 0;
     1.8      func_list = pci_func_list_process(pci_dev_str, template,
     1.9                                        pci_dev_info['func'])
    1.10      for func in func_list:
    1.11          pci_dev = template.copy()
    1.12          pci_dev['func'] = "0x%x" % func
    1.13  
    1.14 +        if len(func_list) == 1:
    1.15 +            # For single-function devices vfunc must be 0
    1.16 +            vfunc = 0
    1.17 +        else:
    1.18 +            # For multi-function virtual devices,
    1.19 +            # identity map the func to vfunc
    1.20 +            vfunc = func
    1.21          if pci_dev_info['vdevfn'] == '':
    1.22              vdevfn = AUTO_PHP_SLOT | vfunc
    1.23          else:
    1.24 @@ -301,7 +307,6 @@ def parse_pci_name_extended(pci_dev_str)
    1.25          pci_dev['vdevfn'] = "0x%02x" % vdevfn
    1.26  
    1.27          pci.append(pci_dev)
    1.28 -        vfunc += 1
    1.29  
    1.30      # For pci attachment and detachment is it important that virtual
    1.31      # function 0 is done last. This is because is virtual function 0 that
     2.1 --- a/tools/python/xen/xm/main.py	Wed Jul 22 14:04:14 2009 +0100
     2.2 +++ b/tools/python/xen/xm/main.py	Wed Jul 22 14:05:26 2009 +0100
     2.3 @@ -2226,17 +2226,9 @@ def xm_pci_list(args):
     2.4      if len(devs) == 0:
     2.5          return
     2.6  
     2.7 -    def f(x):
     2.8 -        # The vfunc shouldn't be used for ordering if the vslot hasn't been
     2.9 -        # assigned as the output looks odd beacuse the vfunc isn't reported
    2.10 -        # but the (physical) function is.
    2.11 -        if x['vdevfn'] & AUTO_PHP_SLOT:
    2.12 -            vdevfn = AUTO_PHP_SLOT
    2.13 -        else:
    2.14 -            vdevfn = x['vdevfn']
    2.15 -        return (vdevfn << 32) | \
    2.16 -                   PCI_BDF(x['domain'], x['bus'], x['slot'], x['func'])
    2.17 -    devs.sort(None, f)
    2.18 +    devs.sort(None,
    2.19 +              lambda x: (x['vdevfn'] - PCI_FUNC(x['vdevfn'])) << 32 |
    2.20 +                         PCI_BDF(x['domain'], x['bus'], x['slot'], x['func']))
    2.21  
    2.22      has_vdevfn = False
    2.23      for x in devs: