2009-03-02 16:18:11 +00:00
|
|
|
/*
|
2012-12-13 14:52:25 +00:00
|
|
|
* virpci.h: helper APIs for managing host PCI devices
|
|
|
|
*
|
2011-12-14 10:50:01 +00:00
|
|
|
* Copyright (C) 2009, 2011-2012 Red Hat, Inc.
|
2009-03-02 16:18:11 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2009-03-02 16:18:11 +00:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Mark McLoughlin <markmc@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_PCI_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_PCI_H__
|
2009-03-02 16:18:11 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
2013-01-16 11:49:54 +00:00
|
|
|
# include "virobject.h"
|
2009-03-02 16:18:11 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
typedef struct _virPCIDevice virPCIDevice;
|
|
|
|
typedef virPCIDevice *virPCIDevicePtr;
|
|
|
|
typedef struct _virPCIDeviceAddress virPCIDeviceAddress;
|
|
|
|
typedef virPCIDeviceAddress *virPCIDeviceAddressPtr;
|
|
|
|
typedef struct _virPCIDeviceList virPCIDeviceList;
|
|
|
|
typedef virPCIDeviceList *virPCIDeviceListPtr;
|
|
|
|
|
|
|
|
struct _virPCIDeviceAddress {
|
2011-08-16 04:28:43 +00:00
|
|
|
unsigned int domain;
|
|
|
|
unsigned int bus;
|
|
|
|
unsigned int slot;
|
|
|
|
unsigned int function;
|
|
|
|
};
|
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
virPCIDevicePtr virPCIDeviceNew(unsigned domain,
|
|
|
|
unsigned bus,
|
|
|
|
unsigned slot,
|
|
|
|
unsigned function);
|
|
|
|
void virPCIDeviceFree(virPCIDevicePtr dev);
|
|
|
|
const char *virPCIDeviceGetName(virPCIDevicePtr dev);
|
|
|
|
|
|
|
|
int virPCIDeviceDetach(virPCIDevicePtr dev,
|
|
|
|
virPCIDeviceListPtr activeDevs,
|
|
|
|
virPCIDeviceListPtr inactiveDevs,
|
|
|
|
const char *driver);
|
|
|
|
int virPCIDeviceReattach(virPCIDevicePtr dev,
|
|
|
|
virPCIDeviceListPtr activeDevs,
|
|
|
|
virPCIDeviceListPtr inactiveDevs,
|
|
|
|
const char *driver);
|
|
|
|
int virPCIDeviceReset(virPCIDevicePtr dev,
|
|
|
|
virPCIDeviceListPtr activeDevs,
|
|
|
|
virPCIDeviceListPtr inactiveDevs);
|
|
|
|
|
|
|
|
void virPCIDeviceSetManaged(virPCIDevice *dev,
|
|
|
|
unsigned managed);
|
|
|
|
unsigned virPCIDeviceGetManaged(virPCIDevice *dev);
|
|
|
|
void virPCIDeviceSetUsedBy(virPCIDevice *dev,
|
|
|
|
const char *used_by);
|
|
|
|
const char *virPCIDeviceGetUsedBy(virPCIDevice *dev);
|
|
|
|
unsigned virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev);
|
|
|
|
void virPCIDeviceSetUnbindFromStub(virPCIDevice *dev,
|
|
|
|
unsigned unbind);
|
|
|
|
unsigned virPCIDeviceGetRemoveSlot(virPCIDevicePtr dev);
|
|
|
|
void virPCIDeviceSetRemoveSlot(virPCIDevice *dev,
|
|
|
|
unsigned remove_slot);
|
|
|
|
unsigned virPCIDeviceGetReprobe(virPCIDevicePtr dev);
|
|
|
|
void virPCIDeviceSetReprobe(virPCIDevice *dev,
|
|
|
|
unsigned reprobe);
|
|
|
|
void virPCIDeviceReattachInit(virPCIDevice *dev);
|
|
|
|
|
|
|
|
|
|
|
|
virPCIDeviceListPtr virPCIDeviceListNew(void);
|
|
|
|
int virPCIDeviceListAdd(virPCIDeviceListPtr list,
|
|
|
|
virPCIDevicePtr dev);
|
|
|
|
virPCIDevicePtr virPCIDeviceListGet(virPCIDeviceListPtr list,
|
|
|
|
int idx);
|
|
|
|
int virPCIDeviceListCount(virPCIDeviceListPtr list);
|
|
|
|
virPCIDevicePtr virPCIDeviceListSteal(virPCIDeviceListPtr list,
|
|
|
|
virPCIDevicePtr dev);
|
|
|
|
virPCIDevicePtr virPCIDeviceListStealIndex(virPCIDeviceListPtr list,
|
|
|
|
int idx);
|
|
|
|
void virPCIDeviceListDel(virPCIDeviceListPtr list,
|
|
|
|
virPCIDevicePtr dev);
|
|
|
|
virPCIDevicePtr virPCIDeviceListFind(virPCIDeviceListPtr list,
|
|
|
|
virPCIDevicePtr dev);
|
|
|
|
int virPCIDeviceListFindIndex(virPCIDeviceListPtr list,
|
|
|
|
virPCIDevicePtr dev);
|
2009-08-14 07:31:11 +00:00
|
|
|
|
2009-08-14 13:20:40 +00:00
|
|
|
/*
|
|
|
|
* Callback that will be invoked once for each file
|
|
|
|
* associated with / used for PCI host device access.
|
|
|
|
*
|
|
|
|
* Should return 0 if successfully processed, or
|
|
|
|
* -1 to indicate error and abort iteration
|
|
|
|
*/
|
2013-01-14 22:11:44 +00:00
|
|
|
typedef int (*virPCIDeviceFileActor)(virPCIDevicePtr dev,
|
|
|
|
const char *path, void *opaque);
|
2009-08-14 13:20:40 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIDeviceFileIterate(virPCIDevicePtr dev,
|
|
|
|
virPCIDeviceFileActor actor,
|
|
|
|
void *opaque);
|
2009-08-14 13:20:40 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIDeviceIsAssignable(virPCIDevicePtr dev,
|
|
|
|
int strict_acs_check);
|
|
|
|
int virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher);
|
2009-12-22 17:21:15 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIGetPhysicalFunction(const char *sysfs_path,
|
|
|
|
virPCIDeviceAddressPtr *phys_fn);
|
2011-08-16 04:28:43 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIGetVirtualFunctions(const char *sysfs_path,
|
|
|
|
virPCIDeviceAddressPtr **virtual_functions,
|
|
|
|
unsigned int *num_virtual_functions);
|
2011-08-16 04:28:43 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIIsVirtualFunction(const char *vf_sysfs_device_link);
|
2011-08-16 04:28:48 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
|
|
|
|
const char *vf_sysfs_device_link,
|
|
|
|
int *vf_index);
|
2011-08-16 04:28:48 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIDeviceAddressGetSysfsFile(virPCIDeviceAddressPtr dev,
|
|
|
|
char **pci_sysfs_device_link);
|
2012-03-06 01:12:23 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIGetNetName(char *device_link_sysfs_path, char **netname);
|
2011-08-16 04:28:48 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIGetSysfsFile(char *virPCIDeviceName,
|
|
|
|
char **pci_sysfs_device_link)
|
2011-12-14 10:50:01 +00:00
|
|
|
ATTRIBUTE_RETURN_CHECK;
|
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIGetAddrString(unsigned domain,
|
|
|
|
unsigned bus,
|
|
|
|
unsigned slot,
|
|
|
|
unsigned function,
|
|
|
|
char **pciConfigAddr)
|
2011-12-14 10:50:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
|
2012-03-06 01:12:23 +00:00
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
|
|
|
|
char **pfname, int *vf_index);
|
2012-03-06 01:12:23 +00:00
|
|
|
|
2009-03-02 16:18:11 +00:00
|
|
|
#endif /* __VIR_PCI_H__ */
|