node_device_driver.h 2.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * node_device.h: node device enumeration
 *
 * Copyright (C) 2008 Virtual Iron Software, Inc.
 * Copyright (C) 2008 David F. Lively
 *
 * 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
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * Author: David F. Lively <dlively@virtualiron.com>
 */

#ifndef __VIR_NODE_DEVICE_H__
25
# define __VIR_NODE_DEVICE_H__
26

27 28 29
# include "internal.h"
# include "driver.h"
# include "node_device_conf.h"
30

31
# define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host/"
32 33
# define LINUX_SYSFS_SCSI_HOST_POSTFIX "device"
# define LINUX_SYSFS_FC_HOST_PREFIX "/sys/class/fc_host/"
34

35 36 37 38
# define VPORT_CREATE 0
# define VPORT_DELETE 1
# define LINUX_SYSFS_VPORT_CREATE_POSTFIX "/vport_create"
# define LINUX_SYSFS_VPORT_DELETE_POSTFIX "/vport_delete"
39

40 41 42
# define SRIOV_FOUND 0
# define SRIOV_NOT_FOUND 1
# define SRIOV_ERROR -1
43

44
# define LINUX_NEW_DEVICE_WAIT_TIME 60
45

46
# ifdef HAVE_HAL
47
int halNodeRegister(void);
48 49
# endif
# ifdef HAVE_UDEV
50
int udevNodeRegister(void);
51
# endif
52

53 54 55
void nodeDeviceLock(virDeviceMonitorStatePtr driver);
void nodeDeviceUnlock(virDeviceMonitorStatePtr driver);

56 57 58 59
void registerCommonNodeFuncs(virDeviceMonitorPtr mon);

int nodedevRegister(void);

60
# ifdef __linux__
61

62
#  define check_fc_host(d) check_fc_host_linux(d)
63 64
int check_fc_host_linux(union _virNodeDevCapData *d);

65
#  define check_vport_capable(d) check_vport_capable_linux(d)
66 67
int check_vport_capable_linux(union _virNodeDevCapData *d);

68
#  define get_physical_function(s,d) get_physical_function_linux(s,d)
69 70 71
int get_physical_function_linux(const char *sysfs_path,
                                union _virNodeDevCapData *d);

72
#  define get_virtual_functions(s,d) get_virtual_functions_linux(s,d)
73 74 75
int get_virtual_functions_linux(const char *sysfs_path,
                                union _virNodeDevCapData *d);

76
#  define read_wwn(host, file, wwn) read_wwn_linux(host, file, wwn)
77 78
int read_wwn_linux(int host, const char *file, char **wwn);

79
# else  /* __linux__ */
80

81 82 83 84 85
#  define check_fc_host(d)
#  define check_vport_capable(d)
#  define get_physical_function(sysfs_path, d)
#  define get_virtual_functions(sysfs_path, d)
#  define read_wwn(host, file, wwn)
86

87
# endif /* __linux__ */
88

89
#endif /* __VIR_NODE_DEVICE_H__ */