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 4/8] qemu-xen: pass-through: rename slot to devfn

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [rfc 4/8] qemu-xen: pass-through: rename slot to devfn
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Wed, 17 Jun 2009 18:07:40 +1000
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>, Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>, Dexuan Cui <dexuan.cui@xxxxxxxxx>
Delivery-date: Wed, 17 Jun 2009 01:17:47 -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: <20090617080736.631945993@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
This is the noisy companion to the previous patch "qemu-xen: pass-through:
use devfn instead of slots as the unit for pass-through". It just renames
slot to devfn in various places.

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

---

Changes

Thu, 21 May 2009 13:09:53 +1000
* Rediff for recent canges made to "qemu-xen: pass-through: use devfn
  instead of slots as the unit for pass-through"

Index: ioemu-remote/hw/pass-through.c
===================================================================
--- ioemu-remote.orig/hw/pass-through.c 2009-06-15 11:25:45.000000000 +1000
+++ ioemu-remote/hw/pass-through.c      2009-06-15 11:25:50.000000000 +1000
@@ -831,7 +831,7 @@ static int token_value(char *token)
 }
 
 static int parse_bdf(char **str, int *seg, int *bus, int *dev, int *func,
-                     char **opt, int *vslot)
+                     char **opt, int *vdevfn)
 {
     char *token, *endptr;
     const char *delim = ":.";
@@ -855,11 +855,11 @@ static int parse_bdf(char **str, int *se
     if (*opt)
     {
         *(*opt)++ = '\0';
-        *vslot = token_value(*opt);
+        *vdevfn = token_value(*opt);
     }
     else
     {
-        *vslot = AUTO_PHP_DEVFN;
+        *vdevfn = AUTO_PHP_DEVFN;
         *opt = token;
     }
 
@@ -892,24 +892,24 @@ static int get_next_keyval(char **option
     return 0;
 }
 
-static int pci_slot_match(int bus, int dev, int func, int slot)
+static int pci_devfn_match(int bus, int dev, int func, int devfn)
 {
-    if (test_pci_slot(slot) == 1 &&
-        dpci_infos.php_devs[slot].r_bus == bus &&
-        dpci_infos.php_devs[slot].r_dev  == dev &&
-        dpci_infos.php_devs[slot].r_func == func )
+    if (test_pci_devfn(devfn) == 1 &&
+        dpci_infos.php_devs[devfn].r_bus == bus &&
+        dpci_infos.php_devs[devfn].r_dev  == dev &&
+        dpci_infos.php_devs[devfn].r_func == func )
         return 1;
     return 0;
 }
 
-/* Insert a new pass-through device into a specific pci slot.
- * input  dom:bus:dev.func@slot, chose free one if slot == AUTO_PHP_DEVFN
- * return -2: requested slot not available
- *        -1: no free slots
- *        >=0: the new hotplug slot
+/* Insert a new pass-through device into a specific pci devfn.
+ * input  dom:bus:dev.func@devfn, chose free one if devfn == AUTO_PHP_DEVFN
+ * return -2: requested devfn not available
+ *        -1: no free devfns
+ *        >=0: the new hotplug devfn
  */
-static int __insert_to_pci_slot(int bus, int dev, int func, int devfn,
-                                char *opt)
+static int __insert_to_pci_devfn(int bus, int dev, int func, int devfn,
+                                 char *opt)
 {
     PCIBus *e_bus = dpci_infos.e_bus;
     int slot;
@@ -917,7 +917,7 @@ static int __insert_to_pci_slot(int bus,
     /* preferred virt pci devfn */
     if ( devfn != AUTO_PHP_DEVFN )
     {
-        if ( !test_pci_slot(devfn) && !pci_devfn_in_use(e_bus, devfn) )
+        if ( !test_pci_devfn(devfn) && !pci_devfn_in_use(e_bus, devfn) )
             goto found;
         return -2;
     }
@@ -926,7 +926,7 @@ static int __insert_to_pci_slot(int bus,
     for ( slot = 0; slot < NR_PCI_DEV; slot++ )
     {
         devfn = PCI_DEVFN(slot, 0);
-        if ( !test_pci_slot(devfn) && !pci_devfn_in_use(e_bus, devfn) )
+        if ( !test_pci_devfn(devfn) && !pci_devfn_in_use(e_bus, devfn) )
             goto found;
     }
 
@@ -942,54 +942,54 @@ found:
     return devfn;
 }
 
-/* Insert a new pass-through device into a specific pci slot.
- * input  dom:bus:dev.func@slot
+/* Insert a new pass-through device into a specific pci devfn.
+ * input  dom:bus:dev.func@devfn
  */
-int insert_to_pci_slot(char *bdf_slt)
+int insert_to_pci_devfn(char *bdf_slt)
 {
-    int seg, bus, dev, func, slot;
+    int seg, bus, dev, func, devfn;
     char *opt;
 
-    if ( !parse_bdf(&bdf_slt, &seg, &bus, &dev, &func, &opt, &slot) )
+    if ( !parse_bdf(&bdf_slt, &seg, &bus, &dev, &func, &opt, &devfn) )
     {
         return -1;
     }
 
-    return __insert_to_pci_slot(bus, dev, func, slot, opt);
+    return __insert_to_pci_devfn(bus, dev, func, devfn, opt);
 
 }
 
-/* Test if a pci slot has a PHP device
+/* Test if a pci devfn has a PHP device
  * 1:  present
  * 0:  not present
- * -1: invalid pci slot input
+ * -1: invalid pci devfn input
  */
-int test_pci_slot(int slot)
+int test_pci_devfn(int devfn)
 {
-    if ( slot < 0 || slot >= NR_PCI_DEVFN )
+    if ( devfn < 0 || devfn >= NR_PCI_DEVFN )
         return -1;
 
-    if ( dpci_infos.php_devs[slot].valid )
+    if ( dpci_infos.php_devs[devfn].valid )
         return 1;
 
     return 0;
 }
 
-/* find the pci slot for pass-through dev with specified BDF */
-int bdf_to_slot(char *bdf_str)
+/* find the pci devfn for pass-through dev with specified BDF */
+int bdf_to_devfn(char *bdf_str)
 {
-    int seg, bus, dev, func, slot, i;
+    int seg, bus, dev, func, devfn, i;
     char *opt;
 
-    if ( !parse_bdf(&bdf_str, &seg, &bus, &dev, &func, &opt, &slot))
+    if ( !parse_bdf(&bdf_str, &seg, &bus, &dev, &func, &opt, &devfn))
     {
         return -1;
     }
 
-    /* locate the virtual pci slot for this VTd device */
+    /* locate the virtual pci devfn for this VTd device */
     for ( i = 0; i < NR_PCI_DEVFN; i++ )
     {
-        if ( pci_slot_match(bus, dev, func, i) )
+        if ( pci_devfn_match(bus, dev, func, i) )
             return i;
     }
 
@@ -3960,7 +3960,7 @@ static int pt_pmcsr_reg_restore(struct p
 }
 
 static struct pt_dev * register_real_device(PCIBus *e_bus,
-        const char *e_dev_name, int e_slot, uint8_t r_bus, uint8_t r_dev,
+        const char *e_dev_name, int e_devfn, uint8_t r_bus, uint8_t r_dev,
         uint8_t r_func, uint32_t machine_irq, struct pci_access *pci_access,
         char *opt)
 {
@@ -4037,7 +4037,7 @@ static struct pt_dev * register_real_dev
 
     /* Register device */
     assigned_device = (struct pt_dev *) pci_register_device(e_bus, e_dev_name,
-                                sizeof(struct pt_dev), e_slot,
+                                sizeof(struct pt_dev), e_devfn,
                                 pt_pci_read_config, pt_pci_write_config);
     if ( assigned_device == NULL )
     {
@@ -4045,7 +4045,7 @@ static struct pt_dev * register_real_dev
         return NULL;
     }
 
-    dpci_infos.php_devs[e_slot].pt_dev = assigned_device;
+    dpci_infos.php_devs[e_devfn].pt_dev = assigned_device;
 
     assigned_device->pci_dev = pci_dev;
     assigned_device->msi_trans_cap = msi_translate;
@@ -4145,7 +4145,7 @@ out:
     return assigned_device;
 }
 
-static int unregister_real_device(int slot)
+static int unregister_real_device(int devfn)
 {
     struct php_dev *php_dev;
     struct pci_dev *pci_dev;
@@ -4155,10 +4155,10 @@ static int unregister_real_device(int sl
     uint32_t bdf = 0;
     int rc = -1;
 
-    if ( test_pci_slot(slot) != 1 )
+    if ( test_pci_devfn(devfn) != 1 )
        return -1;
 
-    php_dev = &dpci_infos.php_devs[slot];
+    php_dev = &dpci_infos.php_devs[devfn];
     assigned_device = php_dev->pt_dev;
 
     if ( !assigned_device )
@@ -4209,7 +4209,7 @@ static int unregister_real_device(int sl
 
     pt_iomul_free(assigned_device);
 
-    /* mark this slot as free */
+    /* mark this devfn as free */
     php_dev->valid = 0;
     php_dev->pt_dev = NULL;
     qemu_free(assigned_device);
@@ -4217,14 +4217,14 @@ static int unregister_real_device(int sl
     return 0;
 }
 
-int power_on_php_slot(int slot)
+int power_on_php_devfn(int devfn)
 {
-    struct php_dev *php_dev = &dpci_infos.php_devs[slot];
+    struct php_dev *php_dev = &dpci_infos.php_devs[devfn];
     struct pt_dev *pt_dev;
     pt_dev =
         register_real_device(dpci_infos.e_bus,
             "DIRECT PCI",
-            slot,
+            devfn,
             php_dev->r_bus,
             php_dev->r_dev,
             php_dev->r_func,
@@ -4238,9 +4238,9 @@ int power_on_php_slot(int slot)
 
 }
 
-int power_off_php_slot(int php_slot)
+int power_off_php_devfn(int php_devfn)
 {
-    return unregister_real_device(php_slot);
+    return unregister_real_device(php_devfn);
 }
 
 int pt_init(PCIBus *e_bus)
Index: ioemu-remote/hw/pci.h
===================================================================
--- ioemu-remote.orig/hw/pci.h  2009-06-15 11:25:45.000000000 +1000
+++ ioemu-remote/hw/pci.h       2009-06-15 11:25:50.000000000 +1000
@@ -261,11 +261,11 @@ PCIBus *pci_bridge_init(PCIBus *bus, int
 #define AUTO_PHP_SLOT  NR_PCI_DEV
 #define AUTO_PHP_DEVFN NR_PCI_DEVFN
 
-int insert_to_pci_slot(char*);
-int test_pci_slot(int);
-int bdf_to_slot(char*);
-int power_on_php_slot(int);
-int power_off_php_slot(int);
+int insert_to_pci_devfn(char *bdf_devfn);
+int test_pci_devfn(int devfn);
+int bdf_to_devfn(char *bdf_str);
+int power_on_php_devfn(int devfn);
+int power_off_php_devfn(int devfn);
 
 /* pci_emulation.c */
 #include "hw/pci_emulation.h"
Index: ioemu-remote/xen-vl-extra.c
===================================================================
--- ioemu-remote.orig/xen-vl-extra.c    2009-06-15 11:25:37.000000000 +1000
+++ ioemu-remote/xen-vl-extra.c 2009-06-15 11:25:50.000000000 +1000
@@ -102,31 +102,31 @@ struct qemu_alarm_timer;
 #ifdef CONFIG_PASSTHROUGH
 void do_pci_del(char *devname)
 {
-    int pci_slot;
+    int devfn;
     char *devname_cpy;
 
     devname_cpy = strdup(devname);
     if (!devname_cpy)
         return;
 
-    pci_slot = bdf_to_slot(devname);
+    devfn = bdf_to_devfn(devname);
 
-    if (pci_slot < 0)
+    if (devfn < 0)
         fprintf(logfile, "Device \"%s\" is not used by a hotplug device.\n",
                 devname_cpy);
     else
-        acpi_php_del(pci_slot);
+        acpi_php_del(devfn);
 
     free(devname_cpy);
 }
 
 void do_pci_add(char *devname)
 {
-    int pci_slot;
+    int devfn;
 
-    pci_slot = insert_to_pci_slot(devname);
+    devfn = insert_to_pci_devfn(devname);
 
-    acpi_php_add(pci_slot);
+    acpi_php_add(devfn);
 }
 
 int pci_emulation_add(char *config_text)
Index: ioemu-remote/hw/piix4acpi.c
===================================================================
--- ioemu-remote.orig/hw/piix4acpi.c    2009-06-15 11:25:45.000000000 +1000
+++ ioemu-remote/hw/piix4acpi.c 2009-06-15 11:25:50.000000000 +1000
@@ -278,7 +278,7 @@ static void acpi_php_writeb(void *opaque
             hotplug_slots->plug_slot = 0;
 
             /* power off the slot */
-            power_off_php_slot(PCI_DEVFN(slot, 0));
+            power_off_php_devfn(PCI_DEVFN(slot, 0));
 
             /* signal the CP ACPI hot remove done. */
             xenstore_record_dm_state("pci-removed");
@@ -318,7 +318,7 @@ static void php_slots_init(void)
 
     /* update the pci slot status */
     for ( i = 0; i < NR_PCI_DEV; i++ ) {
-        if ( test_pci_slot(i) )
+        if ( test_pci_devfn(i) )
             php_slots.status[i] = 0xf;
     }
 
@@ -469,7 +469,7 @@ void acpi_php_del(int devfn)
     slot = PCI_SLOT(devfn);
     func = PCI_FUNC(devfn);
 
-    if ( test_pci_slot(devfn) < 0 ) {
+    if ( test_pci_devfn(devfn) < 0 ) {
         fprintf(logfile, "hot remove: pci slot 0x%02x, function 0x%x "
                 "is not used by a hotplug device.\n", slot, func);
 
@@ -537,7 +537,7 @@ void acpi_php_add(int devfn)
     }
 
     /* power on the function */
-    power_on_php_slot(devfn);
+    power_on_php_devfn(devfn);
 
     /* tell Control panel which slot for the new pass-throgh dev */
     sprintf(ret_str, "0x%02x", devfn);

-- 

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