4 * Copyright (C) 2009 Intel Corporation, Yu Zhao <yu.zhao@intel.com>
6 * PCI Express I/O Virtualization (IOV) support.
8 * Address Translation Service 1.0
11 #include <linux/pci.h>
12 #include <linux/slab.h>
13 #include <linux/mutex.h>
14 #include <linux/export.h>
15 #include <linux/string.h>
16 #include <linux/delay.h>
17 #include <linux/pci-ats.h>
20 #define VIRTFN_ID_LEN 16
22 static inline u8
virtfn_bus(struct pci_dev
*dev
, int id
)
24 return dev
->bus
->number
+ ((dev
->devfn
+ dev
->sriov
->offset
+
25 dev
->sriov
->stride
* id
) >> 8);
28 static inline u8
virtfn_devfn(struct pci_dev
*dev
, int id
)
30 return (dev
->devfn
+ dev
->sriov
->offset
+
31 dev
->sriov
->stride
* id
) & 0xff;
34 static struct pci_bus
*virtfn_add_bus(struct pci_bus
*bus
, int busnr
)
36 struct pci_bus
*child
;
38 if (bus
->number
== busnr
)
41 child
= pci_find_bus(pci_domain_nr(bus
), busnr
);
45 child
= pci_add_new_bus(bus
, NULL
, busnr
);
49 pci_bus_insert_busn_res(child
, busnr
, busnr
);
55 static void virtfn_remove_bus(struct pci_bus
*bus
, int busnr
)
57 struct pci_bus
*child
;
59 if (bus
->number
== busnr
)
62 child
= pci_find_bus(pci_domain_nr(bus
), busnr
);
65 if (list_empty(&child
->devices
))
66 pci_remove_bus(child
);
69 static int virtfn_add(struct pci_dev
*dev
, int id
, int reset
)
74 char buf
[VIRTFN_ID_LEN
];
75 struct pci_dev
*virtfn
;
77 struct pci_sriov
*iov
= dev
->sriov
;
79 virtfn
= alloc_pci_dev();
83 mutex_lock(&iov
->dev
->sriov
->lock
);
84 virtfn
->bus
= virtfn_add_bus(dev
->bus
, virtfn_bus(dev
, id
));
87 mutex_unlock(&iov
->dev
->sriov
->lock
);
90 virtfn
->devfn
= virtfn_devfn(dev
, id
);
91 virtfn
->vendor
= dev
->vendor
;
92 pci_read_config_word(dev
, iov
->pos
+ PCI_SRIOV_VF_DID
, &virtfn
->device
);
93 pci_setup_device(virtfn
);
94 virtfn
->dev
.parent
= dev
->dev
.parent
;
96 for (i
= 0; i
< PCI_SRIOV_NUM_BARS
; i
++) {
97 res
= dev
->resource
+ PCI_IOV_RESOURCES
+ i
;
100 virtfn
->resource
[i
].name
= pci_name(virtfn
);
101 virtfn
->resource
[i
].flags
= res
->flags
;
102 size
= resource_size(res
);
103 do_div(size
, iov
->total_VFs
);
104 virtfn
->resource
[i
].start
= res
->start
+ size
* id
;
105 virtfn
->resource
[i
].end
= virtfn
->resource
[i
].start
+ size
- 1;
106 rc
= request_resource(res
, &virtfn
->resource
[i
]);
111 __pci_reset_function(virtfn
);
113 pci_device_add(virtfn
, virtfn
->bus
);
114 mutex_unlock(&iov
->dev
->sriov
->lock
);
116 virtfn
->physfn
= pci_dev_get(dev
);
117 virtfn
->is_virtfn
= 1;
119 rc
= pci_bus_add_device(virtfn
);
120 sprintf(buf
, "virtfn%u", id
);
121 rc
= sysfs_create_link(&dev
->dev
.kobj
, &virtfn
->dev
.kobj
, buf
);
124 rc
= sysfs_create_link(&virtfn
->dev
.kobj
, &dev
->dev
.kobj
, "physfn");
128 kobject_uevent(&virtfn
->dev
.kobj
, KOBJ_CHANGE
);
133 sysfs_remove_link(&dev
->dev
.kobj
, buf
);
136 mutex_lock(&iov
->dev
->sriov
->lock
);
137 pci_stop_and_remove_bus_device(virtfn
);
138 virtfn_remove_bus(dev
->bus
, virtfn_bus(dev
, id
));
139 mutex_unlock(&iov
->dev
->sriov
->lock
);
144 static void virtfn_remove(struct pci_dev
*dev
, int id
, int reset
)
146 char buf
[VIRTFN_ID_LEN
];
148 struct pci_dev
*virtfn
;
149 struct pci_sriov
*iov
= dev
->sriov
;
151 bus
= pci_find_bus(pci_domain_nr(dev
->bus
), virtfn_bus(dev
, id
));
155 virtfn
= pci_get_slot(bus
, virtfn_devfn(dev
, id
));
162 device_release_driver(&virtfn
->dev
);
163 __pci_reset_function(virtfn
);
166 sprintf(buf
, "virtfn%u", id
);
167 sysfs_remove_link(&dev
->dev
.kobj
, buf
);
169 * pci_stop_dev() could have been called for this virtfn already,
170 * so the directory for the virtfn may have been removed before.
171 * Double check to avoid spurious sysfs warnings.
173 if (virtfn
->dev
.kobj
.sd
)
174 sysfs_remove_link(&virtfn
->dev
.kobj
, "physfn");
176 mutex_lock(&iov
->dev
->sriov
->lock
);
177 pci_stop_and_remove_bus_device(virtfn
);
178 virtfn_remove_bus(dev
->bus
, virtfn_bus(dev
, id
));
179 mutex_unlock(&iov
->dev
->sriov
->lock
);
184 static int sriov_migration(struct pci_dev
*dev
)
187 struct pci_sriov
*iov
= dev
->sriov
;
192 if (!(iov
->cap
& PCI_SRIOV_CAP_VFM
))
195 pci_read_config_word(dev
, iov
->pos
+ PCI_SRIOV_STATUS
, &status
);
196 if (!(status
& PCI_SRIOV_STATUS_VFM
))
199 schedule_work(&iov
->mtask
);
204 static void sriov_migration_task(struct work_struct
*work
)
209 struct pci_sriov
*iov
= container_of(work
, struct pci_sriov
, mtask
);
211 for (i
= iov
->initial_VFs
; i
< iov
->num_VFs
; i
++) {
212 state
= readb(iov
->mstate
+ i
);
213 if (state
== PCI_SRIOV_VFM_MI
) {
214 writeb(PCI_SRIOV_VFM_AV
, iov
->mstate
+ i
);
215 state
= readb(iov
->mstate
+ i
);
216 if (state
== PCI_SRIOV_VFM_AV
)
217 virtfn_add(iov
->self
, i
, 1);
218 } else if (state
== PCI_SRIOV_VFM_MO
) {
219 virtfn_remove(iov
->self
, i
, 1);
220 writeb(PCI_SRIOV_VFM_UA
, iov
->mstate
+ i
);
221 state
= readb(iov
->mstate
+ i
);
222 if (state
== PCI_SRIOV_VFM_AV
)
223 virtfn_add(iov
->self
, i
, 0);
227 pci_read_config_word(iov
->self
, iov
->pos
+ PCI_SRIOV_STATUS
, &status
);
228 status
&= ~PCI_SRIOV_STATUS_VFM
;
229 pci_write_config_word(iov
->self
, iov
->pos
+ PCI_SRIOV_STATUS
, status
);
232 static int sriov_enable_migration(struct pci_dev
*dev
, int nr_virtfn
)
237 struct pci_sriov
*iov
= dev
->sriov
;
239 if (nr_virtfn
<= iov
->initial_VFs
)
242 pci_read_config_dword(dev
, iov
->pos
+ PCI_SRIOV_VFM
, &table
);
243 bir
= PCI_SRIOV_VFM_BIR(table
);
244 if (bir
> PCI_STD_RESOURCE_END
)
247 table
= PCI_SRIOV_VFM_OFFSET(table
);
248 if (table
+ nr_virtfn
> pci_resource_len(dev
, bir
))
251 pa
= pci_resource_start(dev
, bir
) + table
;
252 iov
->mstate
= ioremap(pa
, nr_virtfn
);
256 INIT_WORK(&iov
->mtask
, sriov_migration_task
);
258 iov
->ctrl
|= PCI_SRIOV_CTRL_VFM
| PCI_SRIOV_CTRL_INTR
;
259 pci_write_config_word(dev
, iov
->pos
+ PCI_SRIOV_CTRL
, iov
->ctrl
);
264 static void sriov_disable_migration(struct pci_dev
*dev
)
266 struct pci_sriov
*iov
= dev
->sriov
;
268 iov
->ctrl
&= ~(PCI_SRIOV_CTRL_VFM
| PCI_SRIOV_CTRL_INTR
);
269 pci_write_config_word(dev
, iov
->pos
+ PCI_SRIOV_CTRL
, iov
->ctrl
);
271 cancel_work_sync(&iov
->mtask
);
272 iounmap(iov
->mstate
);
275 static int sriov_enable(struct pci_dev
*dev
, int nr_virtfn
)
280 u16 offset
, stride
, initial
;
281 struct resource
*res
;
282 struct pci_dev
*pdev
;
283 struct pci_sriov
*iov
= dev
->sriov
;
292 pci_read_config_word(dev
, iov
->pos
+ PCI_SRIOV_INITIAL_VF
, &initial
);
293 if (initial
> iov
->total_VFs
||
294 (!(iov
->cap
& PCI_SRIOV_CAP_VFM
) && (initial
!= iov
->total_VFs
)))
297 if (nr_virtfn
< 0 || nr_virtfn
> iov
->total_VFs
||
298 (!(iov
->cap
& PCI_SRIOV_CAP_VFM
) && (nr_virtfn
> initial
)))
301 pci_write_config_word(dev
, iov
->pos
+ PCI_SRIOV_NUM_VF
, nr_virtfn
);
302 pci_read_config_word(dev
, iov
->pos
+ PCI_SRIOV_VF_OFFSET
, &offset
);
303 pci_read_config_word(dev
, iov
->pos
+ PCI_SRIOV_VF_STRIDE
, &stride
);
304 if (!offset
|| (nr_virtfn
> 1 && !stride
))
308 for (i
= 0; i
< PCI_SRIOV_NUM_BARS
; i
++) {
309 bars
|= (1 << (i
+ PCI_IOV_RESOURCES
));
310 res
= dev
->resource
+ PCI_IOV_RESOURCES
+ i
;
314 if (nres
!= iov
->nres
) {
315 dev_err(&dev
->dev
, "not enough MMIO resources for SR-IOV\n");
319 iov
->offset
= offset
;
320 iov
->stride
= stride
;
322 if (virtfn_bus(dev
, nr_virtfn
- 1) > dev
->bus
->busn_res
.end
) {
323 dev_err(&dev
->dev
, "SR-IOV: bus number out of range\n");
327 if (pci_enable_resources(dev
, bars
)) {
328 dev_err(&dev
->dev
, "SR-IOV: IOV BARS not allocated\n");
332 if (iov
->link
!= dev
->devfn
) {
333 pdev
= pci_get_slot(dev
->bus
, iov
->link
);
339 if (!pdev
->is_physfn
)
342 rc
= sysfs_create_link(&dev
->dev
.kobj
,
343 &pdev
->dev
.kobj
, "dep_link");
348 iov
->ctrl
|= PCI_SRIOV_CTRL_VFE
| PCI_SRIOV_CTRL_MSE
;
349 pci_cfg_access_lock(dev
);
350 pci_write_config_word(dev
, iov
->pos
+ PCI_SRIOV_CTRL
, iov
->ctrl
);
352 pci_cfg_access_unlock(dev
);
354 iov
->initial_VFs
= initial
;
355 if (nr_virtfn
< initial
)
358 for (i
= 0; i
< initial
; i
++) {
359 rc
= virtfn_add(dev
, i
, 0);
364 if (iov
->cap
& PCI_SRIOV_CAP_VFM
) {
365 rc
= sriov_enable_migration(dev
, nr_virtfn
);
370 kobject_uevent(&dev
->dev
.kobj
, KOBJ_CHANGE
);
371 iov
->num_VFs
= nr_virtfn
;
376 for (j
= 0; j
< i
; j
++)
377 virtfn_remove(dev
, j
, 0);
379 iov
->ctrl
&= ~(PCI_SRIOV_CTRL_VFE
| PCI_SRIOV_CTRL_MSE
);
380 pci_cfg_access_lock(dev
);
381 pci_write_config_word(dev
, iov
->pos
+ PCI_SRIOV_CTRL
, iov
->ctrl
);
383 pci_cfg_access_unlock(dev
);
385 if (iov
->link
!= dev
->devfn
)
386 sysfs_remove_link(&dev
->dev
.kobj
, "dep_link");
391 static void sriov_disable(struct pci_dev
*dev
)
394 struct pci_sriov
*iov
= dev
->sriov
;
399 if (iov
->cap
& PCI_SRIOV_CAP_VFM
)
400 sriov_disable_migration(dev
);
402 for (i
= 0; i
< iov
->num_VFs
; i
++)
403 virtfn_remove(dev
, i
, 0);
405 iov
->ctrl
&= ~(PCI_SRIOV_CTRL_VFE
| PCI_SRIOV_CTRL_MSE
);
406 pci_cfg_access_lock(dev
);
407 pci_write_config_word(dev
, iov
->pos
+ PCI_SRIOV_CTRL
, iov
->ctrl
);
409 pci_cfg_access_unlock(dev
);
411 if (iov
->link
!= dev
->devfn
)
412 sysfs_remove_link(&dev
->dev
.kobj
, "dep_link");
417 static int sriov_init(struct pci_dev
*dev
, int pos
)
423 u16 ctrl
, total
, offset
, stride
;
424 struct pci_sriov
*iov
;
425 struct resource
*res
;
426 struct pci_dev
*pdev
;
428 if (pci_pcie_type(dev
) != PCI_EXP_TYPE_RC_END
&&
429 pci_pcie_type(dev
) != PCI_EXP_TYPE_ENDPOINT
)
432 pci_read_config_word(dev
, pos
+ PCI_SRIOV_CTRL
, &ctrl
);
433 if (ctrl
& PCI_SRIOV_CTRL_VFE
) {
434 pci_write_config_word(dev
, pos
+ PCI_SRIOV_CTRL
, 0);
438 pci_read_config_word(dev
, pos
+ PCI_SRIOV_TOTAL_VF
, &total
);
443 list_for_each_entry(pdev
, &dev
->bus
->devices
, bus_list
)
448 if (pci_ari_enabled(dev
->bus
))
449 ctrl
|= PCI_SRIOV_CTRL_ARI
;
452 pci_write_config_word(dev
, pos
+ PCI_SRIOV_CTRL
, ctrl
);
453 pci_read_config_word(dev
, pos
+ PCI_SRIOV_VF_OFFSET
, &offset
);
454 pci_read_config_word(dev
, pos
+ PCI_SRIOV_VF_STRIDE
, &stride
);
455 if (!offset
|| (total
> 1 && !stride
))
458 pci_read_config_dword(dev
, pos
+ PCI_SRIOV_SUP_PGSIZE
, &pgsz
);
459 i
= PAGE_SHIFT
> 12 ? PAGE_SHIFT
- 12 : 0;
460 pgsz
&= ~((1 << i
) - 1);
465 pci_write_config_dword(dev
, pos
+ PCI_SRIOV_SYS_PGSIZE
, pgsz
);
468 for (i
= 0; i
< PCI_SRIOV_NUM_BARS
; i
++) {
469 res
= dev
->resource
+ PCI_IOV_RESOURCES
+ i
;
470 i
+= __pci_read_base(dev
, pci_bar_unknown
, res
,
471 pos
+ PCI_SRIOV_BAR
+ i
* 4);
474 if (resource_size(res
) & (PAGE_SIZE
- 1)) {
478 res
->end
= res
->start
+ resource_size(res
) * total
- 1;
482 iov
= kzalloc(sizeof(*iov
), GFP_KERNEL
);
491 iov
->total_VFs
= total
;
492 iov
->offset
= offset
;
493 iov
->stride
= stride
;
496 pci_read_config_dword(dev
, pos
+ PCI_SRIOV_CAP
, &iov
->cap
);
497 pci_read_config_byte(dev
, pos
+ PCI_SRIOV_FUNC_LINK
, &iov
->link
);
498 if (pci_pcie_type(dev
) == PCI_EXP_TYPE_RC_END
)
499 iov
->link
= PCI_DEVFN(PCI_SLOT(dev
->devfn
), iov
->link
);
502 iov
->dev
= pci_dev_get(pdev
);
506 mutex_init(&iov
->lock
);
514 for (i
= 0; i
< PCI_SRIOV_NUM_BARS
; i
++) {
515 res
= dev
->resource
+ PCI_IOV_RESOURCES
+ i
;
522 static void sriov_release(struct pci_dev
*dev
)
524 BUG_ON(dev
->sriov
->num_VFs
);
526 if (dev
!= dev
->sriov
->dev
)
527 pci_dev_put(dev
->sriov
->dev
);
529 mutex_destroy(&dev
->sriov
->lock
);
535 static void sriov_restore_state(struct pci_dev
*dev
)
539 struct pci_sriov
*iov
= dev
->sriov
;
541 pci_read_config_word(dev
, iov
->pos
+ PCI_SRIOV_CTRL
, &ctrl
);
542 if (ctrl
& PCI_SRIOV_CTRL_VFE
)
545 for (i
= PCI_IOV_RESOURCES
; i
<= PCI_IOV_RESOURCE_END
; i
++)
546 pci_update_resource(dev
, i
);
548 pci_write_config_dword(dev
, iov
->pos
+ PCI_SRIOV_SYS_PGSIZE
, iov
->pgsz
);
549 pci_write_config_word(dev
, iov
->pos
+ PCI_SRIOV_NUM_VF
, iov
->num_VFs
);
550 pci_write_config_word(dev
, iov
->pos
+ PCI_SRIOV_CTRL
, iov
->ctrl
);
551 if (iov
->ctrl
& PCI_SRIOV_CTRL_VFE
)
556 * pci_iov_init - initialize the IOV capability
557 * @dev: the PCI device
559 * Returns 0 on success, or negative on failure.
561 int pci_iov_init(struct pci_dev
*dev
)
565 if (!pci_is_pcie(dev
))
568 pos
= pci_find_ext_capability(dev
, PCI_EXT_CAP_ID_SRIOV
);
570 return sriov_init(dev
, pos
);
576 * pci_iov_release - release resources used by the IOV capability
577 * @dev: the PCI device
579 void pci_iov_release(struct pci_dev
*dev
)
586 * pci_iov_resource_bar - get position of the SR-IOV BAR
587 * @dev: the PCI device
588 * @resno: the resource number
589 * @type: the BAR type to be filled in
591 * Returns position of the BAR encapsulated in the SR-IOV capability.
593 int pci_iov_resource_bar(struct pci_dev
*dev
, int resno
,
594 enum pci_bar_type
*type
)
596 if (resno
< PCI_IOV_RESOURCES
|| resno
> PCI_IOV_RESOURCE_END
)
599 BUG_ON(!dev
->is_physfn
);
601 *type
= pci_bar_unknown
;
603 return dev
->sriov
->pos
+ PCI_SRIOV_BAR
+
604 4 * (resno
- PCI_IOV_RESOURCES
);
608 * pci_sriov_resource_alignment - get resource alignment for VF BAR
609 * @dev: the PCI device
610 * @resno: the resource number
612 * Returns the alignment of the VF BAR found in the SR-IOV capability.
613 * This is not the same as the resource size which is defined as
614 * the VF BAR size multiplied by the number of VFs. The alignment
615 * is just the VF BAR size.
617 resource_size_t
pci_sriov_resource_alignment(struct pci_dev
*dev
, int resno
)
620 enum pci_bar_type type
;
621 int reg
= pci_iov_resource_bar(dev
, resno
, &type
);
626 __pci_read_base(dev
, type
, &tmp
, reg
);
627 return resource_alignment(&tmp
);
631 * pci_restore_iov_state - restore the state of the IOV capability
632 * @dev: the PCI device
634 void pci_restore_iov_state(struct pci_dev
*dev
)
637 sriov_restore_state(dev
);
641 * pci_iov_bus_range - find bus range used by Virtual Function
644 * Returns max number of buses (exclude current one) used by Virtual
647 int pci_iov_bus_range(struct pci_bus
*bus
)
653 list_for_each_entry(dev
, &bus
->devices
, bus_list
) {
656 busnr
= virtfn_bus(dev
, dev
->sriov
->total_VFs
- 1);
661 return max
? max
- bus
->number
: 0;
665 * pci_enable_sriov - enable the SR-IOV capability
666 * @dev: the PCI device
667 * @nr_virtfn: number of virtual functions to enable
669 * Returns 0 on success, or negative on failure.
671 int pci_enable_sriov(struct pci_dev
*dev
, int nr_virtfn
)
678 return sriov_enable(dev
, nr_virtfn
);
680 EXPORT_SYMBOL_GPL(pci_enable_sriov
);
683 * pci_disable_sriov - disable the SR-IOV capability
684 * @dev: the PCI device
686 void pci_disable_sriov(struct pci_dev
*dev
)
695 EXPORT_SYMBOL_GPL(pci_disable_sriov
);
698 * pci_sriov_migration - notify SR-IOV core of Virtual Function Migration
699 * @dev: the PCI device
701 * Returns IRQ_HANDLED if the IRQ is handled, or IRQ_NONE if not.
703 * Physical Function driver is responsible to register IRQ handler using
704 * VF Migration Interrupt Message Number, and call this function when the
705 * interrupt is generated by the hardware.
707 irqreturn_t
pci_sriov_migration(struct pci_dev
*dev
)
712 return sriov_migration(dev
) ? IRQ_HANDLED
: IRQ_NONE
;
714 EXPORT_SYMBOL_GPL(pci_sriov_migration
);
717 * pci_num_vf - return number of VFs associated with a PF device_release_driver
718 * @dev: the PCI device
720 * Returns number of VFs, or 0 if SR-IOV is not enabled.
722 int pci_num_vf(struct pci_dev
*dev
)
727 return dev
->sriov
->num_VFs
;
729 EXPORT_SYMBOL_GPL(pci_num_vf
);
732 * pci_vfs_assigned - returns number of VFs are assigned to a guest
733 * @dev: the PCI device
735 * Returns number of VFs belonging to this device that are assigned to a guest.
736 * If device is not a physical function returns -ENODEV.
738 int pci_vfs_assigned(struct pci_dev
*dev
)
740 struct pci_dev
*vfdev
;
741 unsigned int vfs_assigned
= 0;
742 unsigned short dev_id
;
744 /* only search if we are a PF */
749 * determine the device ID for the VFs, the vendor ID will be the
750 * same as the PF so there is no need to check for that one
752 pci_read_config_word(dev
, dev
->sriov
->pos
+ PCI_SRIOV_VF_DID
, &dev_id
);
754 /* loop through all the VFs to see if we own any that are assigned */
755 vfdev
= pci_get_device(dev
->vendor
, dev_id
, NULL
);
758 * It is considered assigned if it is a virtual function with
759 * our dev as the physical function and the assigned bit is set
761 if (vfdev
->is_virtfn
&& (vfdev
->physfn
== dev
) &&
762 (vfdev
->dev_flags
& PCI_DEV_FLAGS_ASSIGNED
))
765 vfdev
= pci_get_device(dev
->vendor
, dev_id
, vfdev
);
770 EXPORT_SYMBOL_GPL(pci_vfs_assigned
);
773 * pci_sriov_set_totalvfs -- reduce the TotalVFs available
774 * @dev: the PCI PF device
775 * @numvfs: number that should be used for TotalVFs supported
777 * Should be called from PF driver's probe routine with
778 * device's mutex held.
780 * Returns 0 if PF is an SRIOV-capable device and
781 * value of numvfs valid. If not a PF with VFS, return -EINVAL;
782 * if VFs already enabled, return -EBUSY.
784 int pci_sriov_set_totalvfs(struct pci_dev
*dev
, u16 numvfs
)
786 if (!dev
->is_physfn
|| (numvfs
> dev
->sriov
->total_VFs
))
789 /* Shouldn't change if VFs already enabled */
790 if (dev
->sriov
->ctrl
& PCI_SRIOV_CTRL_VFE
)
793 dev
->sriov
->driver_max_VFs
= numvfs
;
797 EXPORT_SYMBOL_GPL(pci_sriov_set_totalvfs
);
800 * pci_sriov_get_totalvfs -- get total VFs supported on this devic3
801 * @dev: the PCI PF device
803 * For a PCIe device with SRIOV support, return the PCIe
804 * SRIOV capability value of TotalVFs or the value of driver_max_VFs
805 * if the driver reduced it. Otherwise, -EINVAL.
807 int pci_sriov_get_totalvfs(struct pci_dev
*dev
)
812 if (dev
->sriov
->driver_max_VFs
)
813 return dev
->sriov
->driver_max_VFs
;
815 return dev
->sriov
->total_VFs
;
817 EXPORT_SYMBOL_GPL(pci_sriov_get_totalvfs
);