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 1/9] xend: pass-through: use devfn instead of slots as

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [rfc 1/9] xend: pass-through: use devfn instead of slots as the unit for pass-through
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Wed, 17 Jun 2009 18:08:43 +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:13:28 -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 part of support for multi-function PCI devices in guests

Instead of suppling a slot number to qemu-xen, supply a devfn.

This and subsequent other changes will allow xend to ask
for more than one function to be inserted into a single slot -
by specifying which function of the slot should be used.

This is a minimal patch for this change. A subsequent
patch that has a lot of noise to rename slot to devfn
is intended to follow.

This patch breaks compatibility with qemu-xen and corresponding
patches to qemu-xen are required.

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

--- 

Co-dependent with xen-qemu patch
"qemu-xen: pass-through: use devfn instead of slots as the unit for
 pass-through"

Changes

Wed, 20 May 2009 18:14:38 +1000
* Update for cset 19626:145e49b8574c

Thu, 28 May 2009 22:17:40 +1000
* Update for cset 19662:fe68405201d2

Index: xen-unstable.hg/tools/python/xen/xend/XendConstants.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/XendConstants.py 2009-06-17 
10:05:26.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendConstants.py      2009-06-17 
10:05:39.000000000 +1000
@@ -138,9 +138,11 @@ VTPM_DELETE_SCRIPT = auxbin.scripts_dir(
 
 XS_VMROOT = "/vm/"
 
+NR_PCI_FUNC = 8
 NR_PCI_DEV = 32
-AUTO_PHP_SLOT = NR_PCI_DEV
-AUTO_PHP_SLOT_STR = "%02x" % NR_PCI_DEV
+NR_PCI_DEVFN = NR_PCI_FUNC * NR_PCI_DEV
+AUTO_PHP_DEVFN = NR_PCI_DEVFN
+AUTO_PHP_DEVFN_STR = "%02x" % NR_PCI_DEVFN
 
 #
 # tmem
Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/XendDomainInfo.py        
2009-06-17 10:05:37.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py     2009-06-17 
10:05:39.000000000 +1000
@@ -644,7 +644,7 @@ class XendDomainInfo:
             pci_devs = pci_conf['devs']
             for x in pci_devs:
                 if (int(x['vslot'], 16) == int(new_dev['vslot'], 16) and
-                   int(x['vslot'], 16) != AUTO_PHP_SLOT):
+                   int(x['vslot'], 16) != AUTO_PHP_DEVFN):
                     raise VmError("vslot %s already have a device." % 
(new_dev['vslot']))
 
                 if (pci_dict_cmp(x, new_dev)):
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py  2009-06-17 
10:05:36.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py       2009-06-17 
10:05:39.000000000 +1000
@@ -75,7 +75,7 @@ class PciController(DevController):
             slot = parse_hex(pci_config.get('slot', 0))
             func = parse_hex(pci_config.get('func', 0))            
             vslot = parse_hex(pci_config.get('vslot',
-                                             '0x' + AUTO_PHP_SLOT_STR))
+                                             '0x' + AUTO_PHP_DEVFN_STR))
 
             if pci_config.has_key('opts'):
                 opts = serialise_pci_opts(pci_config['opts'])
Index: xen-unstable.hg/tools/python/xen/util/pci.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/util/pci.py   2009-06-17 
10:05:33.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/util/pci.py        2009-06-17 
10:05:39.000000000 +1000
@@ -16,7 +16,7 @@ import threading
 from xen.util import utils
 from xen.xend import uuid
 from xen.xend import sxp
-from xen.xend.XendConstants import AUTO_PHP_SLOT
+from xen.xend.XendConstants import AUTO_PHP_DEVFN
 from xen.xend.XendSXPDev import dev_dict_to_sxp
 
 PROC_PCI_PATH = '/proc/bus/pci/devices'
@@ -115,6 +115,10 @@ PAGE_MASK=~(PAGE_SIZE - 1)
 # Definitions from Linux: include/linux/pci.h
 def PCI_DEVFN(slot, func):
     return ((((slot) & 0x1f) << 3) | ((func) & 0x07))
+def PCI_SLOT(devfn):
+    return (devfn >> 3) & 0x1f
+def PCI_FUNC(devfn):
+    return devfn & 0x7
 
 def PCI_BDF(domain, bus, slot, func):
     return (((domain & 0xffff) << 16) | ((bus & 0xff) << 8) |
@@ -246,9 +250,9 @@ def parse_pci_name_extended(pci_dev_str)
     out['slot']   = "0x%02x" % int(pci_dev_info['slot'], 16)
     out['func']   = "0x%x"   % int(pci_dev_info['func'], 16)
     if pci_dev_info['vslot'] == '':
-        vslot = AUTO_PHP_SLOT
+        vslot = AUTO_PHP_DEVFN
     else:
-        vslot = int(pci_dev_info['vslot'], 16)
+        vslot = PCI_DEVFN(int(pci_dev_info['vslot'], 16), 0)
     out['vslot'] = "0x%02x" % vslot
     if pci_dev_info['opts'] != '':
         out['opts'] = split_pci_opts(pci_dev_info['opts'])
@@ -259,10 +263,11 @@ def parse_pci_name_extended(pci_dev_str)
 def parse_pci_name(pci_name_string):
     pci = parse_pci_name_extended(pci_name_string)
 
-    if int(pci['vslot'], 16) != AUTO_PHP_SLOT:
+    if int(pci['vslot'], 16) != AUTO_PHP_DEVFN:
         raise PciDeviceParseError(("Failed to parse pci device: %s: " +
-                                   "vslot provided where prohibited: %s") %
-                                  (pci_name_string, pci['vslot']))
+                                   "vslot provided where prohibited: 0x%02x") %
+                                  (pci_name_string,
+                                   PCI_SLOT(int(pci['vslot'], 16))))
     if 'opts' in pci:
         raise PciDeviceParseError(("Failed to parse pci device: %s: " +
                                    "options provided where prohibited: %s") %
Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xm/main.py    2009-06-17 
10:05:35.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/main.py 2009-06-17 10:05:39.000000000 
+1000
@@ -2213,17 +2213,19 @@ def xm_pci_list(args):
 
     has_vslot = False
     for x in devs:
-        if x['vslot'] == AUTO_PHP_SLOT:
+        if x['vslot'] == AUTO_PHP_DEVFN:
             x['show_vslot'] = '-'
+            x['show_vfunc'] = '-'
         else:
-            x['show_vslot'] = "0x%02x" % x['vslot']
+            x['show_vslot'] = "0x%02x" % PCI_SLOT(x['vslot'])
+            x['show_vfunc'] = "0x%x" % PCI_FUNC(x['vslot'])
             has_vslot = True
 
     hdr_str = 'domain bus  slot func'
     fmt_str = '0x%(domain)04x 0x%(bus)02x 0x%(slot)02x 0x%(func)x'
     if has_vslot:
-        hdr_str = 'VSlt ' + hdr_str
-        fmt_str = '%(show_vslot)-4s ' + fmt_str
+        hdr_str = 'VSlt VFn ' + hdr_str
+        fmt_str = '%(show_vslot)-4s %(show_vfunc)-3s ' + fmt_str
 
     print hdr_str
     for x in devs:
@@ -2519,7 +2521,6 @@ def xm_pci_attach(args):
                      config_pci_opts)
 
     if serverType == SERVER_XEN_API:
-
         pci_dev = sxp.children(pci, 'dev')[0]
         domain = int(sxp.child_value(pci_dev, 'domain'), 16)
         bus = int(sxp.child_value(pci_dev, 'bus'), 16)
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py    2009-06-17 
10:05:32.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-17 
10:05:39.000000000 +1000
@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSI
 from xen.xend.XendError import VmError
 from xen.xend.XendDevices import XendDevices
 from xen.xend.PrettyPrint import prettyprintstring
-from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT_STR
+from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_DEVFN_STR
 from xen.xend.xenstore.xstransact import xstransact
 from xen.xend.server.BlktapController import blktap_disk_types
 from xen.xend.server.netif import randomMAC
@@ -1237,7 +1237,7 @@ class XendConfig(dict):
                 'VM': self['uuid'],
                 'PPCI': ppci_uuid,
                 'hotplug_slot': pci_dev.get('vslot',
-                                            '0x' + AUTO_PHP_SLOT_STR)
+                                            '0x' + AUTO_PHP_DEVFN_STR)
             }
 
             dpci_opts = pci_dev.get('opts')

-- 

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