aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2012-11-09 22:27:53 -0500
committerBjorn Helgaas <bhelgaas@google.com>2012-11-09 23:38:53 -0500
commit6b136724691a6f247ada0c6a5f02370ed46de9f4 (patch)
treed4bbf2c49f97c98ca2b5d6cdc4f80ad5aea1e190
parentbff73156d3ad661655e6d9ef04c2284cf3abb0f1 (diff)
PCI: Use spec names for SR-IOV capability fields
Use the same names (almost) as the spec for TotalVFs, InitialVFs, NumVFs. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/iov.c48
-rw-r--r--drivers/pci/pci-sysfs.c10
-rw-r--r--drivers/pci/pci.h8
3 files changed, 33 insertions, 33 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index f6781e42d00d..a32bd9ad0931 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
106 virtfn->resource[i].name = pci_name(virtfn); 106 virtfn->resource[i].name = pci_name(virtfn);
107 virtfn->resource[i].flags = res->flags; 107 virtfn->resource[i].flags = res->flags;
108 size = resource_size(res); 108 size = resource_size(res);
109 do_div(size, iov->total); 109 do_div(size, iov->total_VFs);
110 virtfn->resource[i].start = res->start + size * id; 110 virtfn->resource[i].start = res->start + size * id;
111 virtfn->resource[i].end = virtfn->resource[i].start + size - 1; 111 virtfn->resource[i].end = virtfn->resource[i].start + size - 1;
112 rc = request_resource(res, &virtfn->resource[i]); 112 rc = request_resource(res, &virtfn->resource[i]);
@@ -194,7 +194,7 @@ static int sriov_migration(struct pci_dev *dev)
194 u16 status; 194 u16 status;
195 struct pci_sriov *iov = dev->sriov; 195 struct pci_sriov *iov = dev->sriov;
196 196
197 if (!iov->nr_virtfn) 197 if (!iov->num_VFs)
198 return 0; 198 return 0;
199 199
200 if (!(iov->cap & PCI_SRIOV_CAP_VFM)) 200 if (!(iov->cap & PCI_SRIOV_CAP_VFM))
@@ -216,7 +216,7 @@ static void sriov_migration_task(struct work_struct *work)
216 u16 status; 216 u16 status;
217 struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask); 217 struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask);
218 218
219 for (i = iov->initial; i < iov->nr_virtfn; i++) { 219 for (i = iov->initial_VFs; i < iov->num_VFs; i++) {
220 state = readb(iov->mstate + i); 220 state = readb(iov->mstate + i);
221 if (state == PCI_SRIOV_VFM_MI) { 221 if (state == PCI_SRIOV_VFM_MI) {
222 writeb(PCI_SRIOV_VFM_AV, iov->mstate + i); 222 writeb(PCI_SRIOV_VFM_AV, iov->mstate + i);
@@ -244,7 +244,7 @@ static int sriov_enable_migration(struct pci_dev *dev, int nr_virtfn)
244 resource_size_t pa; 244 resource_size_t pa;
245 struct pci_sriov *iov = dev->sriov; 245 struct pci_sriov *iov = dev->sriov;
246 246
247 if (nr_virtfn <= iov->initial) 247 if (nr_virtfn <= iov->initial_VFs)
248 return 0; 248 return 0;
249 249
250 pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table); 250 pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table);
@@ -294,15 +294,15 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
294 if (!nr_virtfn) 294 if (!nr_virtfn)
295 return 0; 295 return 0;
296 296
297 if (iov->nr_virtfn) 297 if (iov->num_VFs)
298 return -EINVAL; 298 return -EINVAL;
299 299
300 pci_read_config_word(dev, iov->pos + PCI_SRIOV_INITIAL_VF, &initial); 300 pci_read_config_word(dev, iov->pos + PCI_SRIOV_INITIAL_VF, &initial);
301 if (initial > iov->total || 301 if (initial > iov->total_VFs ||
302 (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total))) 302 (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total_VFs)))
303 return -EIO; 303 return -EIO;
304 304
305 if (nr_virtfn < 0 || nr_virtfn > iov->total || 305 if (nr_virtfn < 0 || nr_virtfn > iov->total_VFs ||
306 (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial))) 306 (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial)))
307 return -EINVAL; 307 return -EINVAL;
308 308
@@ -359,7 +359,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
359 msleep(100); 359 msleep(100);
360 pci_cfg_access_unlock(dev); 360 pci_cfg_access_unlock(dev);
361 361
362 iov->initial = initial; 362 iov->initial_VFs = initial;
363 if (nr_virtfn < initial) 363 if (nr_virtfn < initial)
364 initial = nr_virtfn; 364 initial = nr_virtfn;
365 365
@@ -376,7 +376,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
376 } 376 }
377 377
378 kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); 378 kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE);
379 iov->nr_virtfn = nr_virtfn; 379 iov->num_VFs = nr_virtfn;
380 380
381 return 0; 381 return 0;
382 382
@@ -401,13 +401,13 @@ static void sriov_disable(struct pci_dev *dev)
401 int i; 401 int i;
402 struct pci_sriov *iov = dev->sriov; 402 struct pci_sriov *iov = dev->sriov;
403 403
404 if (!iov->nr_virtfn) 404 if (!iov->num_VFs)
405 return; 405 return;
406 406
407 if (iov->cap & PCI_SRIOV_CAP_VFM) 407 if (iov->cap & PCI_SRIOV_CAP_VFM)
408 sriov_disable_migration(dev); 408 sriov_disable_migration(dev);
409 409
410 for (i = 0; i < iov->nr_virtfn; i++) 410 for (i = 0; i < iov->num_VFs; i++)
411 virtfn_remove(dev, i, 0); 411 virtfn_remove(dev, i, 0);
412 412
413 iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); 413 iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE);
@@ -419,7 +419,7 @@ static void sriov_disable(struct pci_dev *dev)
419 if (iov->link != dev->devfn) 419 if (iov->link != dev->devfn)
420 sysfs_remove_link(&dev->dev.kobj, "dep_link"); 420 sysfs_remove_link(&dev->dev.kobj, "dep_link");
421 421
422 iov->nr_virtfn = 0; 422 iov->num_VFs = 0;
423} 423}
424 424
425static int sriov_init(struct pci_dev *dev, int pos) 425static int sriov_init(struct pci_dev *dev, int pos)
@@ -496,7 +496,7 @@ found:
496 iov->pos = pos; 496 iov->pos = pos;
497 iov->nres = nres; 497 iov->nres = nres;
498 iov->ctrl = ctrl; 498 iov->ctrl = ctrl;
499 iov->total = total; 499 iov->total_VFs = total;
500 iov->offset = offset; 500 iov->offset = offset;
501 iov->stride = stride; 501 iov->stride = stride;
502 iov->pgsz = pgsz; 502 iov->pgsz = pgsz;
@@ -529,7 +529,7 @@ failed:
529 529
530static void sriov_release(struct pci_dev *dev) 530static void sriov_release(struct pci_dev *dev)
531{ 531{
532 BUG_ON(dev->sriov->nr_virtfn); 532 BUG_ON(dev->sriov->num_VFs);
533 533
534 if (dev != dev->sriov->dev) 534 if (dev != dev->sriov->dev)
535 pci_dev_put(dev->sriov->dev); 535 pci_dev_put(dev->sriov->dev);
@@ -554,7 +554,7 @@ static void sriov_restore_state(struct pci_dev *dev)
554 pci_update_resource(dev, i); 554 pci_update_resource(dev, i);
555 555
556 pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz); 556 pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz);
557 pci_write_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, iov->nr_virtfn); 557 pci_write_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, iov->num_VFs);
558 pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); 558 pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
559 if (iov->ctrl & PCI_SRIOV_CTRL_VFE) 559 if (iov->ctrl & PCI_SRIOV_CTRL_VFE)
560 msleep(100); 560 msleep(100);
@@ -661,7 +661,7 @@ int pci_iov_bus_range(struct pci_bus *bus)
661 list_for_each_entry(dev, &bus->devices, bus_list) { 661 list_for_each_entry(dev, &bus->devices, bus_list) {
662 if (!dev->is_physfn) 662 if (!dev->is_physfn)
663 continue; 663 continue;
664 busnr = virtfn_bus(dev, dev->sriov->total - 1); 664 busnr = virtfn_bus(dev, dev->sriov->total_VFs - 1);
665 if (busnr > max) 665 if (busnr > max)
666 max = busnr; 666 max = busnr;
667 } 667 }
@@ -732,7 +732,7 @@ int pci_num_vf(struct pci_dev *dev)
732 if (!dev || !dev->is_physfn) 732 if (!dev || !dev->is_physfn)
733 return 0; 733 return 0;
734 else 734 else
735 return dev->sriov->nr_virtfn; 735 return dev->sriov->num_VFs;
736} 736}
737EXPORT_SYMBOL_GPL(pci_num_vf); 737EXPORT_SYMBOL_GPL(pci_num_vf);
738 738
@@ -750,14 +750,14 @@ EXPORT_SYMBOL_GPL(pci_num_vf);
750 */ 750 */
751int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) 751int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
752{ 752{
753 if (!dev || !dev->is_physfn || (numvfs > dev->sriov->total)) 753 if (!dev || !dev->is_physfn || (numvfs > dev->sriov->total_VFs))
754 return -EINVAL; 754 return -EINVAL;
755 755
756 /* Shouldn't change if VFs already enabled */ 756 /* Shouldn't change if VFs already enabled */
757 if (dev->sriov->ctrl & PCI_SRIOV_CTRL_VFE) 757 if (dev->sriov->ctrl & PCI_SRIOV_CTRL_VFE)
758 return -EBUSY; 758 return -EBUSY;
759 else 759 else
760 dev->sriov->drvttl = numvfs; 760 dev->sriov->driver_max_VFs = numvfs;
761 761
762 return 0; 762 return 0;
763} 763}
@@ -768,7 +768,7 @@ EXPORT_SYMBOL_GPL(pci_sriov_set_totalvfs);
768 * @dev: the PCI PF device 768 * @dev: the PCI PF device
769 * 769 *
770 * For a PCIe device with SRIOV support, return the PCIe 770 * For a PCIe device with SRIOV support, return the PCIe
771 * SRIOV capability value of TotalVFs or the value of drvttl 771 * SRIOV capability value of TotalVFs or the value of driver_max_VFs
772 * if the driver reduced it. Otherwise, -EINVAL. 772 * if the driver reduced it. Otherwise, -EINVAL.
773 */ 773 */
774int pci_sriov_get_totalvfs(struct pci_dev *dev) 774int pci_sriov_get_totalvfs(struct pci_dev *dev)
@@ -776,9 +776,9 @@ int pci_sriov_get_totalvfs(struct pci_dev *dev)
776 if (!dev || !dev->is_physfn) 776 if (!dev || !dev->is_physfn)
777 return -EINVAL; 777 return -EINVAL;
778 778
779 if (dev->sriov->drvttl) 779 if (dev->sriov->driver_max_VFs)
780 return dev->sriov->drvttl; 780 return dev->sriov->driver_max_VFs;
781 else 781 else
782 return dev->sriov->total; 782 return dev->sriov->total_VFs;
783} 783}
784EXPORT_SYMBOL_GPL(pci_sriov_get_totalvfs); 784EXPORT_SYMBOL_GPL(pci_sriov_get_totalvfs);
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 99b5f83d2468..2f21991b8bcd 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -421,7 +421,7 @@ static ssize_t sriov_numvfs_show(struct device *dev,
421{ 421{
422 struct pci_dev *pdev = to_pci_dev(dev); 422 struct pci_dev *pdev = to_pci_dev(dev);
423 423
424 return sprintf(buf, "%u\n", pdev->sriov->nr_virtfn); 424 return sprintf(buf, "%u\n", pdev->sriov->num_VFs);
425} 425}
426 426
427/* 427/*
@@ -455,7 +455,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
455 total = pci_sriov_get_totalvfs(pdev); 455 total = pci_sriov_get_totalvfs(pdev);
456 /* Requested VFs to enable < totalvfs and none enabled already */ 456 /* Requested VFs to enable < totalvfs and none enabled already */
457 if ((num_vfs > 0) && (num_vfs <= total)) { 457 if ((num_vfs > 0) && (num_vfs <= total)) {
458 if (pdev->sriov->nr_virtfn == 0) { 458 if (pdev->sriov->num_VFs == 0) {
459 num_vfs_enabled = 459 num_vfs_enabled =
460 pdev->driver->sriov_configure(pdev, num_vfs); 460 pdev->driver->sriov_configure(pdev, num_vfs);
461 if ((num_vfs_enabled >= 0) && 461 if ((num_vfs_enabled >= 0) &&
@@ -467,7 +467,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
467 } else if (num_vfs_enabled < 0) 467 } else if (num_vfs_enabled < 0)
468 /* error code from driver callback */ 468 /* error code from driver callback */
469 return num_vfs_enabled; 469 return num_vfs_enabled;
470 } else if (num_vfs == pdev->sriov->nr_virtfn) { 470 } else if (num_vfs == pdev->sriov->num_VFs) {
471 dev_warn(&pdev->dev, 471 dev_warn(&pdev->dev,
472 "%d VFs already enabled; no enable action taken\n", 472 "%d VFs already enabled; no enable action taken\n",
473 num_vfs); 473 num_vfs);
@@ -475,14 +475,14 @@ static ssize_t sriov_numvfs_store(struct device *dev,
475 } else { 475 } else {
476 dev_warn(&pdev->dev, 476 dev_warn(&pdev->dev,
477 "%d VFs already enabled. Disable before enabling %d VFs\n", 477 "%d VFs already enabled. Disable before enabling %d VFs\n",
478 pdev->sriov->nr_virtfn, num_vfs); 478 pdev->sriov->num_VFs, num_vfs);
479 return -EINVAL; 479 return -EINVAL;
480 } 480 }
481 } 481 }
482 482
483 /* disable vfs */ 483 /* disable vfs */
484 if (num_vfs == 0) { 484 if (num_vfs == 0) {
485 if (pdev->sriov->nr_virtfn != 0) { 485 if (pdev->sriov->num_VFs != 0) {
486 ret = pdev->driver->sriov_configure(pdev, 0); 486 ret = pdev->driver->sriov_configure(pdev, 0);
487 return ret ? ret : count; 487 return ret ? ret : count;
488 } else { 488 } else {
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 553bbba76eec..3c9443ee00e6 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -233,14 +233,14 @@ struct pci_sriov {
233 int nres; /* number of resources */ 233 int nres; /* number of resources */
234 u32 cap; /* SR-IOV Capabilities */ 234 u32 cap; /* SR-IOV Capabilities */
235 u16 ctrl; /* SR-IOV Control */ 235 u16 ctrl; /* SR-IOV Control */
236 u16 total; /* total VFs associated with the PF */ 236 u16 total_VFs; /* total VFs associated with the PF */
237 u16 initial; /* initial VFs associated with the PF */ 237 u16 initial_VFs; /* initial VFs associated with the PF */
238 u16 nr_virtfn; /* number of VFs available */ 238 u16 num_VFs; /* number of VFs available */
239 u16 offset; /* first VF Routing ID offset */ 239 u16 offset; /* first VF Routing ID offset */
240 u16 stride; /* following VF stride */ 240 u16 stride; /* following VF stride */
241 u32 pgsz; /* page size for BAR alignment */ 241 u32 pgsz; /* page size for BAR alignment */
242 u8 link; /* Function Dependency Link */ 242 u8 link; /* Function Dependency Link */
243 u16 drvttl; /* max num VFs driver supports */ 243 u16 driver_max_VFs; /* max num VFs driver supports */
244 struct pci_dev *dev; /* lowest numbered PF */ 244 struct pci_dev *dev; /* lowest numbered PF */
245 struct pci_dev *self; /* this PF */ 245 struct pci_dev *self; /* this PF */
246 struct mutex lock; /* lock for VF bus */ 246 struct mutex lock; /* lock for VF bus */