macvtap.h 3.9 KB
Newer Older
1
/*
2
 * Copyright (C) 2011 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * Copyright (C) 2010 IBM Corporation
 *
 * 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
 *
 * Authors:
 *     Stefan Berger <stefanb@us.ibm.com>
 */

#ifndef __UTIL_MACVTAP_H__
24
# define __UTIL_MACVTAP_H__
25

26
# include <config.h>
27

28 29 30 31 32 33 34 35 36

enum virVirtualPortType {
    VIR_VIRTUALPORT_NONE,
    VIR_VIRTUALPORT_8021QBG,
    VIR_VIRTUALPORT_8021QBH,

    VIR_VIRTUALPORT_TYPE_LAST,
};

37 38 39 40 41 42 43 44 45 46 47
/* the mode type for macvtap devices */
enum virMacvtapMode {
    VIR_MACVTAP_MODE_VEPA,
    VIR_MACVTAP_MODE_PRIVATE,
    VIR_MACVTAP_MODE_BRIDGE,
    VIR_MACVTAP_MODE_PASSTHRU,

    VIR_MACVTAP_MODE_LAST,
};


48 49 50 51 52 53 54 55 56 57 58 59 60 61
# ifdef IFLA_VF_PORT_PROFILE_MAX
#  define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX IFLA_VF_PORT_PROFILE_MAX
# else
#  define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
# endif

/* profile data for macvtap (VEPA) */
typedef struct _virVirtualPortProfileParams virVirtualPortProfileParams;
typedef virVirtualPortProfileParams *virVirtualPortProfileParamsPtr;
struct _virVirtualPortProfileParams {
    enum virVirtualPortType   virtPortType;
    union {
        struct {
            uint8_t       managerID;
62
            uint32_t      typeID; /* 24 bit valid */
63 64 65 66 67 68 69 70 71
            uint8_t       typeIDVersion;
            unsigned char instanceID[VIR_UUID_BUFLEN];
        } virtPort8021Qbg;
        struct {
            char          profileID[LIBVIRT_IFLA_VF_PORT_PROFILE_MAX];
        } virtPort8021Qbh;
    } u;
};

72 73 74 75 76 77 78 79 80 81 82 83 84
enum virVMOperationType {
    VIR_VM_OP_CREATE,
    VIR_VM_OP_SAVE,
    VIR_VM_OP_RESTORE,
    VIR_VM_OP_DESTROY,
    VIR_VM_OP_MIGRATE_OUT,
    VIR_VM_OP_MIGRATE_IN_START,
    VIR_VM_OP_MIGRATE_IN_FINISH,
    VIR_VM_OP_NO_OP,

    VIR_VM_OP_LAST
};

85 86 87 88
# if WITH_MACVTAP

#  include "internal.h"

89
int openMacvtapTap(const char *ifname,
90 91
                   const unsigned char *macaddress,
                   const char *linkdev,
92
                   enum virMacvtapMode mode,
93 94 95
                   int vnet_hdr,
                   const unsigned char *vmuuid,
                   virVirtualPortProfileParamsPtr virtPortProfile,
96
                   char **res_ifname,
97 98
                   enum virVMOperationType vmop,
                   char *stateDir);
99

100
void delMacvtap(const char *ifname,
101 102
                const unsigned char *macaddress,
                const char *linkdev,
103 104 105
                int mode,
                virVirtualPortProfileParamsPtr virtPortProfile,
                char *stateDir);
106

107 108 109 110
int vpAssociatePortProfileId(const char *macvtap_ifname,
                             const unsigned char *macvtap_macaddr,
                             const char *linkdev,
                             const virVirtualPortProfileParamsPtr virtPort,
111 112
                             const unsigned char *vmuuid,
                             enum virVMOperationType vmOp);
113 114 115 116

int vpDisassociatePortProfileId(const char *macvtap_ifname,
                                const unsigned char *macvtap_macaddr,
                                const char *linkdev,
117 118
                                const virVirtualPortProfileParamsPtr virtPort,
                                enum virVMOperationType vmOp);
119

120 121
# endif /* WITH_MACVTAP */

122
VIR_ENUM_DECL(virVirtualPort)
123
VIR_ENUM_DECL(virVMOperation)
124
VIR_ENUM_DECL(virMacvtapMode)
125

126
#endif /* __UTIL_MACVTAP_H__ */