WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [rfc 9/9] xend: pass-through: Implement least-mapping of vir

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [rfc 9/9] xend: pass-through: Implement least-mapping of virtual functions
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Wed, 17 Jun 2009 18:08:51 +1000
Cc: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>, Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>, Dexuan Cui <dexuan.cui@xxxxxxxxx>
Delivery-date: Wed, 17 Jun 2009 01:26:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20090617080842.095632501@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
This is an alternative to identity mapping virtual functions.

It works by assigning the numerically lowest virtual function that is
available.

* The order of assignment is thus dependent on the order that physical
  functions are specified.

  e.g.
  config         physical     virtual
  01.00.0,2  ->  01:00.0  ->  00:07.0
             ->  01:00.2  ->  00:07.1

  is different to

  config         physical     virtual
  01.00.2,0  ->  01:00.2  ->  00:07.0
             ->  01:00.0  ->  00:07.1

* Physical function 0 need not be present

  e.g.
  config         physical     virtual
  01.00.1,2  ->  01:00.1  ->  00:07.0
             ->  01:00.2  ->  00:07.1

* Functions from the same physical multi-function device
  may be exported as multiple multi-function and single-function devices

  e.g.
  01.00.0,2  ->  01:00.0  ->  00:07.0
             ->  01:00.2  ->  00:07.1
  and
  01.00.1,3  ->  01:00.1  ->  00:08.1
             ->  01:00.3  ->  00:08.1
  and
  01.00.5    ->  01:00.5  ->  00:09.0


N.B: This is intended for testing and discussion,
     it may well violate hardware constraints.

Cc: Dexuan Cui <dexuan.cui@xxxxxxxxx>
Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xm/main.py    2009-06-14 
23:55:31.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/main.py 2009-06-14 23:55:47.000000000 
+1000
@@ -2222,9 +2222,17 @@ def xm_pci_list(args):
     if len(devs) == 0:
         return
 
-    devs.sort(None,
-              lambda x: (x['vdevfn'] - PCI_FUNC(x['vdevfn'])) << 32 |
-                        PCI_BDF(x['domain'], x['bus'], x['slot'], x['func']))
+    def f(x):
+       # The vfunc shouldn't be used for ordering if the vslot hasn't been
+       # assigned as the output looks odd beacuse the vfunc isn't reported
+       # but the (physical) function is.
+       if x['vdevfn'] & AUTO_PHP_SLOT:
+           vdevfn = AUTO_PHP_SLOT
+       else:
+           vdevfn = x['vdevfn']
+        return (vdevfn << 32) | \
+              PCI_BDF(x['domain'], x['bus'], x['slot'], x['func'])
+    devs.sort(None, f)
 
     has_vdevfn = False
     for x in devs:
Index: xen-unstable.hg/tools/python/xen/util/pci.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/util/pci.py   2009-06-14 
23:55:31.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/util/pci.py        2009-06-14 
23:55:31.000000000 +1000
@@ -293,19 +293,13 @@ def parse_pci_name_extended(pci_dev_str)
     # Virtual slot assignment takes place here if specified in the bdf,
     # else it is done inside qemu-xen, as it knows which slots are free
     pci = []
+    vfunc = 0;
     func_list = pci_func_list_process(pci_dev_str, template,
                                       pci_dev_info['func'])
     for func in func_list:
         pci_dev = template.copy()
         pci_dev['func'] = "0x%x" % func
 
-        if len(func_list) == 1:
-            # For single-function devices vfunc must be 0
-            vfunc = 0
-        else:
-            # For multi-function virtual devices,
-            # identity map the func to vfunc
-            vfunc = func
         if pci_dev_info['vdevfn'] == '':
             vdevfn = AUTO_PHP_SLOT | vfunc
         else:
@@ -313,6 +307,7 @@ def parse_pci_name_extended(pci_dev_str)
         pci_dev['vdevfn'] = "0x%02x" % vdevfn
 
         pci.append(pci_dev)
+        vfunc += 1
 
     # For pci attachment and detachment is it important that virtual
     # function 0 is done last. This is because is virtual function 0 that

-- 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel