virnetdevvportprofile.h 4.3 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 27 28

# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40

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

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

40
typedef enum {
41 42 43 44 45 46 47 48 49 50
    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
51
} virNetDevVPortProfileOp;
52 53
VIR_ENUM_DECL(virNetDevVPortProfileOp)

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

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

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


bool virNetDevVPortProfileEqual(virNetDevVPortProfilePtr a,
                                virNetDevVPortProfilePtr b);

83 84 85 86 87 88 89 90 91
int virNetDevVPortProfileCheckComplete(virNetDevVPortProfilePtr virtport,
                                       bool generateMissing);
int virNetDevVPortProfileCheckNoExtras(virNetDevVPortProfilePtr virtport);

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

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

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


111
#endif /* LIBVIRT_VIRNETDEVVPORTPROFILE_H */