virnetdevvportprofile.h 4.5 KB
Newer Older
1
/*
2
 * Copyright (C) 2009-2013 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13 14
 *
 * 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
15
 * License along with this library.  If not, see
O
Osier Yang 已提交
16
 * <http://www.gnu.org/licenses/>.
17 18
 */

19 20
#ifndef LIBVIRT_VIRNETDEVVPORTPROFILE_H
# define LIBVIRT_VIRNETDEVVPORTPROFILE_H
21 22

# include "internal.h"
23
# include "viruuid.h"
24
# include "virutil.h"
25
# include "virmacaddr.h"
26
# include "virenum.h"
27 28 29

# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40

30
typedef enum virNetDevVPortProfile {
31 32 33
    VIR_NETDEV_VPORT_PROFILE_NONE,
    VIR_NETDEV_VPORT_PROFILE_8021QBG,
    VIR_NETDEV_VPORT_PROFILE_8021QBH,
A
Ansis Atteka 已提交
34
    VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH,
35
    VIR_NETDEV_VPORT_PROFILE_MIDONET,
36 37

    VIR_NETDEV_VPORT_PROFILE_LAST,
38
} virNetDevVPortProfileType;
39
VIR_ENUM_DECL(virNetDevVPort);
40

41
typedef enum {
42 43 44 45 46 47 48 49 50 51
    VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
    VIR_NETDEV_VPORT_PROFILE_OP_SAVE,
    VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
    VIR_NETDEV_VPORT_PROFILE_OP_DESTROY,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_OUT,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH,
    VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,

    VIR_NETDEV_VPORT_PROFILE_OP_LAST
52
} virNetDevVPortProfileOp;
53
VIR_ENUM_DECL(virNetDevVPortProfileOp);
54

A
Ansis Atteka 已提交
55
/* profile data for macvtap (VEPA) and openvswitch */
56 57 58
typedef struct _virNetDevVPortProfile virNetDevVPortProfile;
typedef virNetDevVPortProfile *virNetDevVPortProfilePtr;
struct _virNetDevVPortProfile {
59
    int           virtPortType; /* enum virNetDevVPortProfile */
60 61
    /* these members are used when virtPortType == 802.1Qbg */
    uint8_t       managerID;
62
    bool          managerID_specified;
63
    uint32_t      typeID; /* 24 bit valid */
64
    bool          typeID_specified;
65
    uint8_t       typeIDVersion;
66
    bool          typeIDVersion_specified;
67
    unsigned char instanceID[VIR_UUID_BUFLEN];
68
    bool          instanceID_specified;
69 70

    /* this member is used when virtPortType == 802.1Qbh|openvswitch */
71
    /* this is a null-terminated character string */
72 73
    char          profileID[LIBVIRT_IFLA_VF_PORT_PROFILE_MAX];

74
    /* this member is used when virtPortType == openvswitch|midonet */
75
    unsigned char interfaceID[VIR_UUID_BUFLEN];
76
    bool          interfaceID_specified;
77
    /* NB - if virtPortType == NONE, any/all of the items could be used */
78 79 80 81 82
};


bool virNetDevVPortProfileEqual(virNetDevVPortProfilePtr a,
                                virNetDevVPortProfilePtr b);
83 84
int virNetDevVPortProfileCopy(virNetDevVPortProfilePtr *dst,
                              const virNetDevVPortProfile *src);
85

86 87 88 89 90 91 92 93 94
int virNetDevVPortProfileCheckComplete(virNetDevVPortProfilePtr virtport,
                                       bool generateMissing);
int virNetDevVPortProfileCheckNoExtras(virNetDevVPortProfilePtr virtport);

int virNetDevVPortProfileMerge3(virNetDevVPortProfilePtr *result,
                                virNetDevVPortProfilePtr fromInterface,
                                virNetDevVPortProfilePtr fromNetwork,
                                virNetDevVPortProfilePtr fromPortgroup);

95
int virNetDevVPortProfileAssociate(const char *ifname,
96
                                   const virNetDevVPortProfile *virtPort,
97
                                   const virMacAddr *macvtap_macaddr,
98
                                   const char *linkdev,
99
                                   int vf,
100
                                   const unsigned char *vmuuid,
101
                                   virNetDevVPortProfileOp vmOp,
102
                                   bool setlink_only)
103
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
104 105

int virNetDevVPortProfileDisassociate(const char *ifname,
106
                                      const virNetDevVPortProfile *virtPort,
107
                                      const virMacAddr *macvtap_macaddr,
108
                                      const char *linkdev,
109
                                      int vf,
110
                                      virNetDevVPortProfileOp vmOp)
111
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
112 113


114
#endif /* LIBVIRT_VIRNETDEVVPORTPROFILE_H */